Let me clarify: I want git
to not care about whether line endings are CRLF or LF on checkin/commit. I understand there is no way at the moment to make git
not care if a file has mixed line endings, although I would love a workaround to this, just in case; I just want it not to care whether all line endings in a file are CRLF or LF.
I recently set many file extensions in my system .gitattributes
file, /etc/gitattributes
(using MSysGit
), to tell git
which extensions are usually text or binary. For most of the files I want git
to think are text, I set the extension
*.extension text=auto
because this will tell git
that files with these extensions should have the general system line endings. Now I am regretting that decision, as I am seeing how many files are, for one reason or another, automatically given LF line endings instead of CRLF. Now, after tinkering with this and other settings, I have been getting errors similar to
$ git add -A && git commit -m "signup/in/out now possible through passport"
fatal: LF would be replaced by CRLF in node_modules/mongoose/node_modules/ms/package.json
on a lot of files I try to check in. In this case, it seems to be npm
that's causing these files to be created as LF instead of CRLF, but I'm sure there are many other causes.
To be honest, I personally don't care which type of line endings a specific file has, as long as I can read and edit these files in my editing tool(s) of choice, as the vast majority of the time the line endings don't have any special function besides being, well, line endings. If it really matters, I can always do a quick conversion with unix2dos
or dos2unix
. However, git
is notoriously finicky with line endings, and I don't want it to accidentally mark a text file as binary or vice versa, hence why I have been changing all these defaults.
How do I make git
check in all text files as LF-line-ended files, and check them out as CRLF, but not care whether they have CRLF or LF endings in my actual working tree? Alternatively, is there a way to have git
convert all the text files with LF endings to CRLF in my working tree as well, instead of giving the warning and giving up?
EDIT It seems my issue was not with my gitattributes
files, but with my core.safecrlf
setting in my gitconfig
.