首页 > 解决方案 > Git status 在 cygwin 和 git bash (windows 10) 中给出不同的结果

问题描述

我已经安装了 cygwin(和使用 cygwin 包管理器的 git)和git bash for windows。

我刚刚使用 cygwin shell 克隆了一个存储库,然后在存储库的根目录中打开了一个 git bash shell 和一个 cygwin shell。

然后我git status从每个 shell 执行。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

所以对于两个炮弹core.filemode=true

关于为什么 git bash 选择文件权限更改的任何建议?

标签: windowsgitcygwin

解决方案


尝试:

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

如果这样可以解决问题,那么问题就是行尾设置。

如果更改报告为typechange,则问题可能出在 simlink 和解决方案上:

git config core.symlinks true

此外,请确保在提到的存储库中本地应用这些设置,而不仅仅是全局。


推荐阅读