I have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this:
Set
core.autocrlf
tofalse
everywhere,Follow the instructions here (echoed on GitHub's help pages) to convert the repository to contain only LF line-endings, and thereafter set
core.autocrlf
totrue
on Windows andinput
on OS X. The problem with doing this is that if I have any binary files in the repository that:- are not correctly marked as binary in gitattributes, and
- happen to contain both CRLFs and LFs,
they will be corrupted. It is possible my repository contains such files.
So why shouldn't I just turn off Git's line-ending conversion? There are a lot of vague warnings on the web about having core.autocrlf
switched off causing problems, but very few specific ones; the only that I've found so far are that kdiff3 cannot handle CRLF endings (not a problem for me), and that some text editors have line-ending issues (also not a problem for me).
The repository is internal to my company, and so I don't need to worry about sharing it with people with different autocrlf settings or line-ending requirements.
Are there any other problems with just leaving line-endings as-is that I am unaware of?
autocrlf
to false. – Arterioleautocrlf
to false. I'm looking for reasons to set it to true. – Tshirtautocrlf
set tofalse
). I have written an answer to begin to address the opposite (set totrue
), but nothing very definitive yet. – Arterioleautocrlf = input
: it seems to be the perfect resolution between the two extremes: you keep your repo clean from CRLF crap, and locally Windows developers can use whatever they want without their local files having anything magic done automatically to them. (They may want LF locally for various reasons, sotrue
is bad, in my opinion.) I can't see any downsides to usingautocrlf = input
. – Latonaautocrlf = input
makesstash --patch
fail with "Cannot remove worktree changes" – Kweilinautocrlf = input
? – Latonaautocrlf
setting. The problematic file was stored with CRLF in the repo -- maybe this is unsupported combination? – Kweilinautocrlf = input
or just with--patch
? – Latona--stash
switch. – Kweilininput
always, so that win users dont have to worry about, and so that its cleaned on commit on my mac. it causes major binary issues without. – Reynolds