Reputation: 1008
I have a git repository whose files' line endings should be CRLF or LR on the checkedout depending on the specific file. For instance, I want that all *.sh files to be checked out with LR line endings while all *.bat files with CRLF.
I've been trying to pull this off with no results, next is my .gitattributes
file:
* 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
When I open a .sh
file or a .bat
file both line endings are CRLF. What am I doing wrong?
Note: I develop on a Windows computer.
EDIT: System, global and local configuration
System:
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
Global:
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
[email protected]
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
push.default=matching
Local:
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
Also, GitHub's documentation states the following:
Optionally, you can configure the way Git manages line endings on a per-repository basis by configuring a special .gitattributes file. This file is committed into the repository and overrides an individual's core.autocrlf setting, ensuring consistent behavior for all users, regardless of their Git settings.
EDIT 2:
If I set core.autocrlf
to false
and comment all the lines of .gitattributes
then both .sh
and .bat
files are opened with LF line endings.
Upvotes: 2
Views: 1753
Reputation: 78703
The eol
attribute value, like most of Git, is case sensitive. You want:
*.sh eol=lf
*.bat eol=crlf
Upvotes: 10