This is amazing. With a gazillion posts on the Internet about core.autocrlf
and .gitattributes
I am still unable to figure out what to write in .gitattributes
to express core.autocrlf = false
Can anyone clear the mist around it? I do not need all the fancy cases, just give me core.autocrlf = false
in .gitattributes
. Nothing more, but nothing less.
gitattributes file allows you to specify the files and paths attributes that should be used by git when performing git actions, such as git commit , etc. In other words git automatically saves the file according to the attributes specified, every time a file is created or saved.
autocrlf is set to true, Git will automatically convert Windows line endings ( 0x0D 0x0A ) to Unix line endings ( 0x0A ) when adding/commit files to the index/repository and do the reverese when doing the opposite. The idea of this behavior is to ensure that file hashes stay the same regardless of their line endings.
Using core. autocrlf=true on Windows works as expected. All files from the repo (which should have LF line endings in this scenario) are converted to CRLF line endings on checkout to a Windows PC. All files are converted back to LF line endings on commit from a Windows PC.
The default for core. autocrlf is false, meaning that Git will not adjust the end of line, which could lead to CRLF files ending up in the repository (bad). Therefore, it is generally best to set the above configuration for Linux and Windows to ensure that the repository will only contain files with LF .
If you don't want line ending conversion on a file, set the -text
attribute. To turn off conversion on all files, set:
* -text
Note that this doesn't mean "this file isn't text" - that would be the binary
attribute - it means "don't do text manipulations (line ending changes) on it".
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