我正在运行 Windows 10,并在 Cygwin 命令行上使用 Cygwin 的 git,并在 VS Code、PowerShell 等应用程序中使用 Windows git。
我有一个 .gitattributes
文件,其中包含如下条目:
text eol=crlf
*.ahk text eol=crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.css text
*.java text
*.js text
*.md text eol=crlf
*.sh text eol=lf
*.txt text eol=crlf
*.xml text
但是,我发现在 Cygwin 或 PowerShell 上交替运行 git status
会重复显示所有文件需要修改,具体取决于我上次检查它们的文件。我该如何获取两者同意并遵守我的 .gitattributes
?
回应@VonC的建议
2019 年 4 月 2 日星期二中午 12:32:15
在 Cygwin 上我这样做:
$ git config --global core.autocrlf
false
$ echo "* text=auto" >>.gitattributes
$ git add --renormalize .
$ git commit -m "Introduce end-of-line normalization"
... snip
$ git push
... snip
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
然后在 PowerShell 中
> git config --global core.autocrlf
false
> git status
... snip.. every single file listed.. again!
最佳答案
确保在 Cygwin 环境中,git config core.autocrlf 设置为 false
git config --global core.autocrlf false
这样,Git 就不会自动更改文件 eol,并且会坚持其 .gitattributes
指令。
关于git - *.bat text eol=crlf 但 git 仍然更改行结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55446507/