Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
*.bat text eol=crlf,但git仍会更改行尾_Git_Powershell_Cygwin_Gitattributes - Fatal编程技术网

*.bat text eol=crlf,但git仍会更改行尾

*.bat text eol=crlf,但git仍会更改行尾,git,powershell,cygwin,gitattributes,Git,Powershell,Cygwin,Gitattributes,我正在运行Windows 10,在Cygwin命令行上使用Cygwin的git,在VS代码、PowerShell等应用程序中使用Windows git 我有一个.gittributes文件,其中包含如下条目: text eol=crlf *.ahk text eol=crlf *.bat text eol=crlf *.cmd text eol=crlf *.css text *.java text *.js text *.md

我正在运行Windows 10,在Cygwin命令行上使用Cygwin的git,在VS代码、PowerShell等应用程序中使用Windows git

我有一个
.gittributes
文件,其中包含如下条目:

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
时,根据我上次使用哪个文件将其全部签入,会反复显示所有需要修改的文件。。我如何让两者同意并遵守我的
.gittributes

回应@VonC的建议 2019年4月2日星期二下午12:32:15

在Cygwin上,我这样做:

$git config--global core.autocrlf
假的
$echo“*text=auto”>>.gittattributes
$git add——重新规范化。
$git commit-m“引入行尾规范化”
... 剪
$git推送
... 剪
$git状态
论分行行长
您的分支机构是最新的“来源/主”。
没什么要承诺的,正在清理树
然后在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,并且会坚持其
.gittributes
指令。

我会试试,但为什么我的
.gittributes
文件还不足以解决这个问题?项目特定的配置不应该覆盖全局配置吗?@RobertMarkBram应该覆盖。但eol指令可能会受到这一全局设置的影响。尝试一下,如这里()a
git add--renormalize.
(使用git 2.21+),看看您的gitattributes指令是否被强制执行。