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

I have a Git installation, so it does not capture inconsistent line endings. The problem with this is a whole bunch of files that change, although they are not. What am I typing so that these files have line endings 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 be doing what I thought besides this problem:

 autocrlf = true 
+46
git
Oct 21 '09 at 1:18
source share
5 answers

You can simply remove and reinstall the corrupt files from the index as follows:

 rm <files> git checkout -- <files> 

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

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

On the GNU system, you can use a slightly more secure pipe, but in any case, you should not have spaces or other separators in your names.

 git diff -z --name-only --diff-filter=M | xargs -0 rm -- 
+16
Oct 21 '09 at 6:23
source share

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

If you are in a clean state , that is, immediately after the commit, and you do not have unauthorized changes , forcing re-checking and deleting the index should do the trick:

The git reset --hard HEAD command below will cause your current branch to point to the last commit, and all uncommitted code will be lost. Be sure to lock the code or take a backup

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

This, I think, will synchronize the workspace files and index (staging area) in order to follow the crlf settings.

+59
Oct 21 '09 at 9:02
source share

I had this problem when creating a new Xcode project. My solution for this problem:

In terminal entry

 $: git config --global --edit 

Then, in the git config file, change safecrlf to false. My settings:

 [core] autocrlf = input safecrlf = false 

I know that git has cmd command line tools for this, but they do not work for me. And then Xcode creates git repos without any problems.

+31
07 Oct '12 at 10:12
source share

The only thing I can think of is to check if core.safecrlf is core.safecrlf to warn .

git config --get core.safecrlf

I think the possible values ​​are true , false and warn . I believe that setting to false will solve the warning, although this might not be a good idea.

+23
Oct 21 '09 at 1:30
source share

Try it, it worked for me:

 cd src/au/policy/dao dos2unix 

If there are other files in this folder, you will want to split it into the following (otherwise, it will try to do this for each file in any subdirectories, which may take some time):

 cd src/au/policy/dao dos2unix EmailQueue.java dos2unix EmailQueueFactory.java dos2unix PolicyPublisher.java 

It worked quickly on my machine and fixed all line endings, and it is a bit simpler and simpler than some of these other fixes.

+2
Jun 27. '12 at 13:50
source share



All Articles