Git状态在Cygwin和Git Bash(Windows 10)中的结果不同

4

我已经安装了Cygwin(使用Cygwin软件包管理器)和 Windows 的 Git Bash。

我刚刚使用Cygwin shell克隆了一个仓库,然后在仓库的根目录中打开了Git Bash shell和Cygwin shell。

然后我从每个shell中执行git status。Git Bash发现了一个更改(文件权限),但是Cygwin没有发现,我正在尝试理解其中的原因。

以下是详细信息:

Git Bash(显示修改文件)

$ git --version
git version 2.23.0.windows.1
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   script.sh

no changes added to commit (use "git add" and/or "git commit -a")

$ git diff
diff --git a/script.sh b/script.sh
old mode 100755
new mode 100644

$ git config -l | grep core
core.symlinks=true
core.autocrlf=false
core.fscache=true
core.editor='C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin
core.editor='C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession
core.autocrlf=false
core.preloadindex=true
core.fscache=true
core.filemode=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

Cygwin(未发现更改)
$ git --version
git version 2.21.0
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ git config -l | grep core
core.editor='C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession
core.autocrlf=false
core.preloadindex=true
core.fscache=true
core.filemode=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

因此,对于两个shell都设置core.filemode=true

有什么建议可以解释git bash为什么能够检测到文件权限的更改吗?

2个回答

3

尝试:

git config core.filemode false 
git config core.autocrlf true

如果这解决了问题,那么行结束设置就是问题所在。

如果更改被报告为typechange,则问题可能是符号链接,解决方案如下:

git config core.symlinks true

同时,请确保在所提到的仓库中本地应用这些设置,而不仅仅是全局应用。


尝试添加更多信息,说明这个回答如何解决问题。 - Venkataraman R

-1

但我不想让git忽略chmod更改——而且这也没有真正回答我的问题,即为什么会有差异。 - u123
2
Windows和POSIX文件模式不对称。Windows模型比POSIX用户/组/其他X读取/写入/执行模型具有更细的粒度。请注意,ls -l显示rwx位后面有一个+,表示存在比POSIX模型显示的更多ACL。 - Doug Henderson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接