1

I am using Git for Windows 1.9.5; my remote repository has mixed line endings (some CRLF some LF). I would like to normalize the remote repository to entirely LF.

My settings:

git config core.eol lf
git config core.autocrlf false
.gitattributes * text=auto 

I have tried:

Refreshing a respoitory after changing line endings

git rm --cached -r .
git reset --hard
git status

The gitattributes documentation

rm .git/index     # Remove the index to force git to
git reset         # re-scan the working directory
git status        # Show files that will be normalized

This SO answer

git rm --cached -rf .
git diff --cached --name-only -z | xargs -n 50 -0 git add -f
git ls-files -z | xargs -0 rm
git checkout .
git status 

After the git status, I open a sampling of files in a text editor and expect them to have changed from CRLF to LF line endings, but none have.

What do I need to do to change all line endings in both my local and the remote repository to LF?

Community
  • 1
  • 1
PaulH
  • 7,759
  • 8
  • 66
  • 143

1 Answers1

-1

You want to set CRLF on the remote repository. Are you sure? Would anybody else object?

After committing your changes have you pushed them to the remote?

in your .gitattributes you need to set

eol=crlf 
text=auto

when you do your git status you should notice that you have lots of "changed" files. If you commit these then, that should be the eel's changed.

robert
  • 4,612
  • 2
  • 29
  • 39
  • This is a comment, not an answer. – Makoto Feb 05 '15 at 20:14
  • Yes, I am sure. No, I have not yet committed or pushed any changes, because I do not yet have any satisfactory changes to make. That is the purpose of this question - to determine how to make the change to commit. – PaulH Feb 05 '15 at 20:14
  • @Makato eh it is an answer. He needs to push the changes. – robert Feb 05 '15 at 20:16
  • You hadn't added that last sentence by the time I read it, and it doesn't seem like you're entirely confident in your solution. I'll give you that it's now somewhat "an answer". – Makoto Feb 05 '15 at 20:18
  • It is not entirely clear what exactly you're suggesting I put in the `.gitattributes` file. Can you show the exact syntax you intend? – PaulH Feb 05 '15 at 20:24
  • I've made the change you suggested and `git status` does show many files changed, but they all still have CRLF line endings. – PaulH Feb 05 '15 at 20:29
  • I see the problem. If I `git add .` I get `warning: CRLF will be replaced by LF in src/foo.c. The file will have its original line endings in your working directory.` The files are the same locally, but will have the desired LF endings in the repository. – PaulH Feb 05 '15 at 20:41
  • Looks like Makoto owes me an apology :) – robert Feb 05 '15 at 20:52