Git diff报告本地更改'旧模式'/'新模式'

mit*_*mit 6 filesystems git file-permissions

有2台机器,A和B.还有2个分支,p16和c2.

A有一个ext3文件系统,但在B上,存档位于带有vfat的truecrypt驱动器上,mount显示rw,uid = 1000,gid = 1000,umask = 077

A使用sshfs将B的目录树链接到其目录树中,然后使用文件系统将A推入B的p16.

现在有一些权限问题:

B$ git status
# On branch p16
nothing to commit (working directory clean)
B$ git checkout c2
Switched to branch 'c2'
B$ git checkout p16
error: You have local changes to 'help.txt'; cannot switch branches.
Run Code Online (Sandbox Code Playgroud)

git diff现在显示所有文件的更改模式:

B$git diff
diff --git a/help.txtt b/help.txt
old mode 100644
new mode 100755
diff --git a/169.txt b/169.txt
old mode 100644
new mode 100755
... 
(a list with all files having their mode changed follows)
...
Run Code Online (Sandbox Code Playgroud)

我想问题是本地文件系统是一个vfat truecrypt容器,文件系统不允许其他机器期望的权限.

我有什么想法可以更好地将2台机器与不同的文件系统联系起来?

mit*_*mit 8

如果操作系统的文件权限在该位置不起作用,则可能会出现使用git的此类问题.例如,挂载外部文件系统时.

meagar在对上述问题的评论中指出了解决方案:

只要确保你(在[core]部分内)有一条线

filemode=false
Run Code Online (Sandbox Code Playgroud)

在.git/config中,它会告诉git忽略它正在跟踪的文件的可执行位.

另一种做同样事情的方法是转到终端中git repo的根目录并输入:

git config core.filemode false
Run Code Online (Sandbox Code Playgroud)

请注意,偶尔需要更改此设置,但最好保留默认行为.在许多情况下,git正确跟踪文件权限非常重要,因此您的项目可以正常工作.