tags:

views:

400

answers:

4

I have setup git so it doesnt 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
+3  A: 

Only thing I can think of is to check if core.safecrlf is set to warn.

git config --get core.safecrlf

I think possible values are true, false, and warn. I believe that you should have it set to false.

If that's not the issue, then it might not be configurable.

Bob Aman
+1  A: 

You can just delete and re-checkout the offending files from the index like this:

rm <files>
git checkout -- <files>

Or, if they are the only modified files (be careful with this command), you can script it like this:

git diff --name-only --diff-filter=M | xargs rm --
git checkout -- .

On a GNU system you can use a slightly safer pipe, but you don't appear to have spaces or other delimiting characters in your filenames in any case.

git diff -z --name-only --diff-filter=M | xargs -0 rm --
Charles Bailey
+1  A: 

This might happen if you change core.autocrlf config variable (if I understand your problem correctly).

If you are at clean state, i.e. just after commit, and you don't have uncomitted changes, forced re-checkout and removing index should do the trick:

$ rm .git/index
$ git reset --hard HEAD

That, I think, would sync both working area files, and the index (staging area) to follow crlf settings.

Jakub Narębski
A: 

set autocrlf =false ,the issue is dispear;

小和尚