On our system, we used to be able to convert all CRLF to LF while committing file into git. Now this feature is gone.
Here is what I've done:
git config --global core.autocrlf false
After doing the above, I use the following command to check:
git config --list
The result is:
...
core.autocrlf=input
...
core.autocrlf=false
...
It's very puzzling. While there's two entries of core.autocrlf
, and the first one is core.autocrlf=input
? If I unset core.autocrlf
using:
git config --global --unset core.autocrlf
I still get one entry when I list git config:
core.autocrlf=input
Step 2:
After I did git config --global core.autocrlf false
, I add * text=auto
into .gitattributes
file.
But git still does not automatically convert line break for me.
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.
fix-git-line-endings # With the exception that we are forcing LF instead of converting to windows style. #Set LF as your line ending default. #Save your current files in Git, so that none of your work is lost. #Remove the index and force Git to rescan the working directory.
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.
core. autocrlf = input This means that Git will process all text files and make sure that CRLF is replaced with LF when writing that file to the object database.
Since git1.8.1rc1 :
"git config --get" used to diagnose presence of multiple definitions of the same variable in the same configuration file as an error, but it now applies the "last one wins" rule used by the internal configuration logic
So your second setting apply.
For more explaination on option for core.autoctrlf :
If you’re on a Windows machine, set it to true – this converts LF endings into CRLF when you check out code:
$ git config --global core.autocrlf true
You can tell Git to convert CRLF to LF on commit but not the other way around by setting core.autocrlf to input:
$ git config --global core.autocrlf input
If you’re a Windows programmer doing a Windows-only project, then you can turn off this functionality, recording the carriage returns in the repository by setting the config value to false:
$ git config --global core.autocrlf false
more explanation : http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace
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