使用CRLF和LF文件的Git存储库?

时间:2016-05-12 15:08:42

标签: git newline line-endings core.autocrlf lf

我有一个git存储库,其文件'根据特定文件的不同,行结尾应该是CRLF或LR。例如,我想要使用LR行结尾检出所有* .sh文件,而所有带有CRLF的* .bat文件。

我一直试图将其关闭但没有结果,接下来是我的.gitattributes文件:

* text=auto
#
# Declare files that will always have CRLF line endings on checkout.
#

*.sh text eol=LF

#
# Declare files that will always have LF line endings on checkout.
#

*.bat text eol=CRLF

#
# Denote all files that are truly binary and should not be modified.
#

*.zip binary
*.tar binary
*.exe binary
*.dll binary
*/dropbear binary
*update-binary binary

当我打开.sh文件或.bat文件时,两个行结尾都是CRLF。我做错了什么?

注意:我是在Windows计算机上开发的。

编辑:系统,全局和本地配置

系统:

core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true

全局:

merge.tool=kdiff3
diff.guitool=kdiff3
core.editor="C:/Program Files (x86)/GitExtensions/GitExtensions.exe" fileeditor
core.autocrlf=true
credential.helper=!'C:\Users\XXXX\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
user.name=xxxxx.xxxx
user.email=xxxx.xxxx@xxxxx.com
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
push.default=matching

本地:

core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=https://github.com/XXXXXX/xxxxxx.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.v2.10.0.remote=origin
branch.v2.10.0.merge=refs/heads/v2.10.0
branch.v2.10.1.remote=origin
branch.v2.10.1.merge=refs/heads/v2.10.1

此外,GitHub's documentation声明如下:

  

或者,您可以通过配置特殊的.gitattributes文件来配置Git基于每个存储库管理行结尾的方式。此文件将提交到存储库并覆盖单个核心.autocrlf设置,以确保所有用户的行为一致,无论其Git设置如何。

编辑2:

如果我将core.autocrlf设置为false并对.gitattributes的所有行进行评论,则会使用LF行结尾打开.sh.bat个文件。< / p>

1 个答案:

答案 0 :(得分:5)

与大多数Git一样,$digest already in progress属性值区分大小写。你想要:

$timeout