我在使用 git 设置文件权限时遇到问题。我想将存储库中的所有文件设置为 644。当我第一次clone存储存储库时,这些文件是不同权限的混合:
-rw------- 1 username group 2305 Oct 25 15:16 addquotes.sas
-rw------- 1 username group 675 Oct 25 15:16 ama_permission.sas
-rw------- 1 username group 1581 Oct 25 15:16 append_words.sas
-rwx------ 1 username group 3688 Oct 25 15:16 sasv9_u8.cfg
-rwx------ 1 username group 1489 Oct 25 15:16 backtest/bt_means.sas
-rwx------ 1 username group 490 Oct 25 15:16 backtest/correct_vname.sas
-rwx------ 1 username group 838 Oct 25 15:16 backtest/gen_random_samples.sas
Run Code Online (Sandbox Code Playgroud)
为了尝试解决这个问题,我运行了find . -type f | xargs chmod 644. 这会更改文件系统上的权限,但当我执行以下操作时,只有少数显示为已修改git status:
modified: sasv9_u8.cfg
modified: backtest/bt_means.sas
modified: backtest/correct_vname.sas
modified: backtest/gen_random_samples.sas
Run Code Online (Sandbox Code Playgroud)
深入挖掘后,我注意到显示为已修改的文件设置了所有者执行位。如果我运行find . -type f | xargs chmod 744(744vs 644,设置所有者执行位),那么所有文件都会出现在git status命令中。
有没有办法让 git 识别权限而不需要在所有者上设置执行位?这种行为看起来很奇怪。
值得一提的有两点:
git不存储文件的整个unix权限范围:它只存储“常规文件”和“可执行文件”,git行为类似于正常过程,并且不会尝试绕过您的umask;group您看不到或部分的访问权限的原因other可能是因为您的 umask 设置为0077“常规文件”将被签出为-rw-rw-rw--- 减去您的 umask ;“可执行文件”将再次被检出-rwxrwxrwx,减去您的 umask。
关于你所看到的:
0077没有权限),因此“常规文件”被检出为“可执行文件”为groupother-rw--------rwx------chmod 644在文件上运行,git检测到以前可执行的文件不再可执行,并且这些文件出现,chmod 744可以git检测“可执行”文件的更改:在我的机器上,它看起来git只检查(linux)可执行标志集以user确定文件是否应该存储为可执行文件;预计会检测到“常规文件”的更改。如何“修复”这个问题:
Xchmod 选项,只有在至少设置了一个可执行标志时,该选项才会设置可执行标志:# you seem to want to give rw (and possibly x) access to the group :
chmod -R g+rwX *
# perhaps r (and possibly x) to "others" :
chmod -R o+rX *
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |