繁体   English   中英

Git 状态在 cygwin 和 git bash(Windows 10)中给出不同的结果

[英]Git status gives different results in cygwin and git bash (windows 10)

I have installed cygwin (and git using the cygwin package manager) and git bash for windows.

I have just cloned a repository using cygwin shell and then opened a git bash shell and a cygwin shell in the root of the repository.

然后我从每个 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

所以对于两个外壳core.filemode=true

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

尝试:

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

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

如果更改被报告为typechange ,那么问题可能是 simlinks 和解决方案:

git config core.symlinks true

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

发出此命令

git config core.fileMode false

在两个回购中。

请参阅如何使 Git 忽略文件模式 (chmod) 更改?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM