Make Git "LF will be replaced by CRLF" warnings go away

Viewed 56103

I have setup Git so it doesn't commit inconsistent line endings. The problem with that is a whole pile of files appear modified even though they are not. What do I type to make these files have the line endings fixed on the local side?

# git checkout dev
M   src/au/policy/dao/EmailQueue.java
M   src/au/policy/dao/EmailQueueFactory.java
M   src/au/policy/dao/PolicyPublisher.java
Already on 'dev'

# git diff
warning: LF will be replaced by CRLF in src/au/policy/dao/EmailQueue.java
warning: LF will be replaced by CRLF in src/au/policy/dao/EmailQueueFactory.java
warning: LF will be replaced by CRLF in src/au/policy/dao/PolicyPublisher.java

This is what I added to my git config file which seems to do what I intended aside from this issue:

autocrlf = true
7 Answers

Note that note all of the above fixes may work for you, for example you might have received the code through a simple file transfer. You can accept each warning by pressing ENTER, but on on large repos that can take ages. Another way to ignore the conversion on code that has already been checked-out and edited is to create a patch file:

git diff > changes.patch

In my case, after setting autocrlf variable to true, then running

git stash

and then

git stash pop

everything cleared out

Related