我试图在一个包含windows和unix特定文件的共享存储库中对行尾进行规范化,但我无法让它按照我期望的方式工作。
我们都是在Windows机器上开发的,但要求行结尾(取决于文件类型)是LF或CRLF。开发人员已经被建议将autocrlf设置为false,这样一些需要CRLF存在的文件就不会在存储库中更改(有windows和unix文件格式的混合),并在必要时手动更改行尾。
有人建议使用gitattribute会在一定程度上减轻对应该使用哪些文件结尾的监管需求,但我一直无法让这一点发挥作用。
以下是我的用户git设置:
[core]
eol = native
bare = false
filemode = false
hideDotFiles = dotGitOnly
ignorecase = true
repositoryformatversion = 0
symlinks = false
autocrlf = true
editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession -noPluginprogramdata git设置:
[core]
fscache = true存储库git设置:
[core]
logallrefupdates = true.gitattributes文件:
# convert all to lf
* text eol=lf
# convert these to windows line endings
*.sbm text eol=crlf
*.sbp text eol=crlf
*.sin text eol=crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ini text eol=crlf
*.inf text eol=crlf
/strataclient/BubbleHelp/* text eol=crlf
# don't touch binary files
*.dot binary
*.dll binary
*.exe binary
*.ocx binary
*.lic binary
*.cfn binary为了测试它,我创建了一个小的提交,其中包含.gitattributes文件(我一直在修改它以测试不同的组合),然后运行以下命令:
git rm --cached -r .
git reset --hard它似乎改变了一些行的结尾,但并不是我所期望的方式。
我尝试过遵循各种指南,但似乎都没有做出预期的影响深远的改变。我希望所有的文本文件都被更改为LF (例如java、properties、txt),除非它是CRLF中列出的类型之一(例如cmd、bat)。
发布于 2019-07-04 19:25:51
我偶然发现了这个问题,我很好奇,在2+多年之后,这还是一个问题吗?
不管怎么说!在最近的Git版本中,您可以在提交.gitattributes文件之后执行git add --renormalize,如下所示:Configuring Git to handle line endings
https://stackoverflow.com/questions/42536609
复制相似问题