Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to express core.autocrlf = false with .gitattributes?

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.

like image 395
mark Avatar asked Oct 25 '18 19:10

mark


People also ask

What should be included in Gitattributes?

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.

What should Autocrlf be set to?

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.

What is core Autocrlf true?

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.

What is the default value of core Autocrlf?

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 .


1 Answers

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".

like image 127
Edward Thomson Avatar answered Oct 03 '22 07:10

Edward Thomson