出于某种原因,当我最初从存储库中获取我的git项目时,我在工作副本中获得了大量文件,这些文件没有对它们进行任何可识别的更改,但是仍然在我的unstaged changes区域中出现.
我在Windows XP上使用Git Gui,当我去查看文件时看看有什么变化.我只看到:
old mode 100755
new mode 100644
Run Code Online (Sandbox Code Playgroud)
有谁知道这意味着什么?
如何从我的未分级更改列表中获取这些文件?(非常讨厌必须通过100个文件,只是挑选我最近编辑过的文件并想要提交).
Amb*_*ber 1188
这看起来像我的unix文件权限模式(755= rwxr-xr-x,644= rw-r--r--) - 旧模式包括+ x(可执行)标志,新模式不包括.
这个msysgit问题的回复建议将core.filemode设置为false以解决问题:
git config core.filemode false
Run Code Online (Sandbox Code Playgroud)
小智 95
将core.filemode设置为false确实有效.但是你要确保〜/ .gitconfig中的设置不被.git/config中的设置覆盖.
K. *_*bol 28
当在 Windows 和 Linux/Unix 机器之间克隆 repo 时,通常会发生这种情况。
只需告诉 git 忽略文件模式更改。这里有几种方法可以做到这一点:
仅为当前存储库配置:
git config core.filemode false
Run Code Online (Sandbox Code Playgroud)
全局配置:
git config --global core.filemode false
Run Code Online (Sandbox Code Playgroud)
在 ~/.gitconfig 中添加:
[core]
filemode = false
Run Code Online (Sandbox Code Playgroud)
只需选择其中之一。
Sco*_*eke 22
我在使用旧硬盘驱动器中的工作文件复制git repo时遇到了这个问题.问题源于所有者和权限从旧驱动器/机器更改为新驱动器/机器的事实.它的长短是运行以下命令来理顺(感谢超级用户的回答):
sudo chmod -R -x . # remove the executable bit from all files
Run Code Online (Sandbox Code Playgroud)
前一个命令实际上将解决git diff报告的差异,但会撤销列出目录的能力,因此ls ./失败了ls: .: Permission denied.解决这个问题:
sudo chmod -R +X . # add the executable bit only for directories
Run Code Online (Sandbox Code Playgroud)
坏消息是,如果你确实有任何想要保存可执行文件的文件,比如.sh脚本,你需要还原那些文件.您可以使用以下命令为每个文件执行此操作:
chmod +x ./build.sh # where build.sh is the file you want to make executable again
Run Code Online (Sandbox Code Playgroud)
小智 19
我也遇到过同样的问题。这救了我的命:
这会将所有权限恢复为 diff 的权限,因此除了对文件所做的更改之外,您什么都没有。
https://gist.github.com/jtdp/5443498
git diff -p -R --no-color \
| grep -E "^(diff|(old|new) mode)" --color=never \
| git apply
Run Code Online (Sandbox Code Playgroud)
更多详细信息请参见/sf/answers/308586491/
公认的 set 答案git config core.filemode false有效,但会产生后果。设置core.filemode为 false 告诉 git 忽略文件系统上的任何可执行位更改,因此它不会将此视为更改。如果您确实需要在将来随时对此存储库进行可执行位更改,则必须手动执行此操作,或设置core.filemode回 true。
如果所有修改的文件都应具有模式 100755,则一个不太重要的替代方案是执行类似的操作
chmod 100755 $(git ls-files --modified)
Run Code Online (Sandbox Code Playgroud)
这只是改变了模式,不多也不少,没有额外的影响。
(就我而言,这是由于 OneDrive 与 MacOS 上的文件系统同步所致;通过不更改core.filemode,我保留了将来可能再次发生模式更改的可能性;就我而言,我想知道如果它再次发生,改变core.filemode就会对我隐藏它,这是我不想要的)
小智 5
此解决方案会将 git 文件权限从 100755 更改为 100644,并将更改推送回 bitbucket 远程存储库。
查看您的存储库的文件权限:git ls-files --stage
如果 100755 而你想要 100644
然后运行这个命令:
git ls-files --stage | sed 's/\t/ /g' | cut -d' ' -f4 | xargs git update-index --chmod=-x
现在再次检查您的存储库的文件权限:git ls-files --stage
现在提交您的更改:
git status
git commit -m "restored proper file permissions"
git push
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
173662 次 |
| 最近记录: |