Git chmod 问题:结帐螺丝 exec 位

Bol*_*wyn 10 git chmod

在 Ubuntu 和 Debian 下,当我之后尝试结帐时,最后提交的文件正在设置执行位。这很奇怪,让我发疯:

$ ls -l file
-rw-r--r-- ... file

# on branch master:
$ git commit -m 'mode is 644' file
[master 0123456] mode is 644
 1 files changed, 1 insertions(+), 1 deletions(-)
# All ok

$ git checkout dev-branch
Switched to branch 'dev-branch'
# Seemingly all ok, but file now has the exec bit set

$ git merge master
Updating 6543210..0123456
error: Your local changes to 'file' would be overwritten by merge.  Aborting.
Please, commit your changes or stash them before you can merge.
# Oops...

$ ls -l file
-rwxr-xr-x ... file
Run Code Online (Sandbox Code Playgroud)

有没有人知道什么时候以及为什么执行位滑入?core.filemode设置为true

我在分支切换期间在 vim 中打开了文件,如果这很重要的话。

附录 1:这是结帐,权限被搞砸了。我可以一直玩游戏:

$ git br
* master
  dev-branch

$ git diff
diff --git a/file b/file
old mode 100644
new mode 100755

$ chmod 644 file

$ git diff

$ git checkout dev-branch

$ git diff
diff --git a/file b/file
old mode 100644
new mode 100755

$ chmod 644 file

$ git diff

$ git checkout master

$ git diff
diff --git a/file b/file
old mode 100644
new mode 100755

# ...and so on ad inf.
Run Code Online (Sandbox Code Playgroud)

附录 2:顺便说一下,对于此存储库中我提交的每个文件,都会发生这种情况。成功提交后,我无法在未经许可的情况下切换分支。

har*_*ymc 12

不是 Git 用户,但我相信 Git 存储了整个文件权限掩码。

这意味着您曾经将文件设置为可执行文件,Git 将其提取并复制到存储库中。因此,您必须在提交之前更改文件的权限掩码本身。

要使 Git 忽略此类更改,请使用

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

git-config(1)

   core.fileMode
       If false, the executable bit differences between the index and the
       working copy are ignored; useful on broken filesystems like FAT.
       See git-update-index(1). True by default.
Run Code Online (Sandbox Code Playgroud)

  • 我必须同意 git 开发人员的意见,即脂肪被打破了 (4认同)
  • 好的,这是文件系统。我无法在另一台机器上重现它,该目录是通过 NFS 挂载的。正如我所说,在主机上是 CIFS。当我在 git 邮件列表上询问时,我得到了答案,CIFS 在执行位方面被破坏了。该死! (3认同)
  • @dolmen:http://comments.gmane.org/gmane.comp.version-control.git/160861 :-) (2认同)