【问题标题】:Git status gives different results in cygwin and git bash (windows 10)Git status 在 cygwin 和 git bash (windows 10) 中给出不同的结果
【发布时间】:2020-01-21 05:37:44
【问题描述】:

我已经安装了 cygwin(以及使用 cygwin 包管理器的 git)和用于 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 获取文件权限更改的任何建议?

【问题讨论】:

    标签: windows git cygwin


    【解决方案1】:

    试试:

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

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

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

    git config core.symlinks true
    

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

    【讨论】:

    • 尝试添加更多信息,这是如何回答问题的。
    【解决方案2】:

    发出这个命令

    git config core.fileMode false
    

    在两个存储库中。

    How do I make Git ignore file mode (chmod) changes?

    【讨论】:

    • 但我不希望 git 忽略 chmod 更改 - 而且它并没有真正回答我为什么会有差异的问题。
    • Windows 和 POSIX 文件模式不是对称的。 Window 模型比 POSIX 用户/组/其他 X 读/写/执行模型具有更精细的粒度。请注意,ls -l 在 rwx 位之后显示一个 +,这表明有效的 ACL 比 POSIX 模型所能显示的要多。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 2023-03-03
    • 1970-01-01
    • 2017-02-14
    • 2013-04-01
    • 1970-01-01
    • 2018-05-12
    相关资源
    最近更新 更多