Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does a git repository have its own local value for core.autocrlf that overrides the global one?

As per this question, I understand that core.autocrlf=true in git will cause CRLF to LF translations.

However when I type : git config core.autocrlf

I see: false

However, when I stage modified files that are already in the repo, I still get these warnings:

Warning: CRLF will be replaced by LF in File1.X.
The file will have its original line endings in your working directory.

My guess is that the repo copy of the file is already set to "autocrlf=true".

Questions: A. How do I query whether a file or git repo is already forcing AutoCrlf? B. How do I turn it autocrlf off?

like image 276
Warren P Avatar asked Sep 09 '12 15:09

Warren P


People also ask

What does git core Autocrlf do?

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 git config global core Autocrlf input?

The git config core. autocrlf command is used to change how Git handles line endings. It takes a single argument. On Windows, you simply pass true to the configuration.

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.

Should I use CRLF or LF?

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.

Where do I put the Gitattributes file?

gitattributes file in one of your directories (normally the root of your project) or in the . git/info/attributes file if you don't want the attributes file committed with your project.


1 Answers

Git allows you to override your global setting on a per-repository basis with a .gitattributes file. You put it in the root directory of the repository, and becomes a file committed as part of the repository. I suspect this is happening in your case.

Github has a good page on this: https://help.github.com/articles/dealing-with-line-endings

In short, you can use the text attribute to set the line endings for a particular file extension. For instance, forcing sln files to CRLF would require the following line in a .gitattributes file :

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
like image 126
mlangsworth Avatar answered Sep 20 '22 17:09

mlangsworth