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
You should use core. autocrlf input and core. eol input . Or just don't let git change the line endings at all with autocrlf false and get rid of highlighting of crlfs in diffs, etc with core.
In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have an LF.
text eol=crlf Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux. text eol=lf Git will always convert line endings to LF on checkout. You should use this for files that must keep LF endings, even on Windows.
Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.
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:
The below command
git reset --hard HEAD
will make your current branch to point to the latest commit and all uncommitted code will be lost. Make sure to commit the code or take the backup
$ 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.
I had this problem when creating new Xcode project. My solution for this problem:
In terminal write
$: git config --global --edit
Then in git config file change safecrlf to false. My settings:
[core] autocrlf = input safecrlf = false
I know git have cmd line tools for this but they don't work for me. And then Xcode create git repos without any problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With