Git 不是忽略文件模式更改 (chmod),为什么?

Git is not ignoring file mode changes (chmod), why?

在开始之前,我应该说我也已经看过 this post and ,但出于某种原因,那里提供的解决方案对我不起作用。我的存储库在 ~/sources 下,所以每个命令都是来自该路径的 运行。这就是我所做的:

将文件模式更改为 false:

$ git config --global core.filemode false

检查全局配置:

$ git config --list
...
core.filemode=false
core.repositoryformatversion=0
core.bare=false
core.logallrefupdates=true
...

重新初始化存储库:

$ git init
Reinitialized existing Git repository in /home/rperez/sources/.git/

查看需要添加|提交的内容:

$ git status

然后我得到一个包含存储库中所有文件的列表。

我正在使用:

$ git --version
git version 2.9.3

更新:为两个不同的文件添加了 git 差异

$ git status
...
    modified:   testing/test-valid-swasset-update.php
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    library/mpdf60/ttfontdata/dejavusanscondensedI.GDEFdata.php
...

git diff 以上文件的输出:

$ git diff testing/test-valid-swasset-update.php
diff --git a/testing/test-valid-swasset-update.php b/testing/test-valid-swasset-update.php
old mode 100755
new mode 100644

我在这里缺少什么?

本地配置覆盖全局配置设置

问题中的 diff 输出表明 local git 配置已将 filemode 设置为 true。这可能是预期的行为,因为为 repo 创建的默认配置定义了这个:

-> git init
Initialized empty Git repository in /tmp/foo/.git/
-> cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true

更改 filemode 的全局配置不会影响这一点,因此实际上 git config --global core.filemode false 不会做任何事情,因为它总是在本地被覆盖。

因此,要更改此 repo 的文件模式,请更改本地配置:

$ git config core.filemode false
$ git config core.filemode
false

考虑到 它有可能会起作用,尽管它对我不起作用。

您可以通过以下方式验证本地设置: git 配置 --local --list

...并像这样设置本地值:

git 配置 --local core.filemode false