12

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?

Community
  • 1
  • 1
Warren P
  • 58,696
  • 38
  • 168
  • 301
  • I would like to know if you can have a "local" copy of the .gitattributes file that you DON'T check into source control? I'd like to have some repos be "windows style" settings and only 1 repo to be LINUX style, without forcing all users of that repo to use LINUX. Is this possible? – atom88 Aug 20 '20 at 21:21
  • Can you put in a git global setting that only applies locally to a particular directory (i.e. REPO)? I want some repos to be WINDOWS and some to be LINUX style line endings? – atom88 Aug 20 '20 at 21:22

1 Answers1

7

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
mlangsworth
  • 347
  • 2
  • 8