1

I am running Windows 10 and use Cygwin's git on the Cygwin command line and use Windows git in applications like VS Code, PowerShell etc.

I have a .gitattributes file with entries like the following:

text eol=crlf

*.ahk     text eol=crlf
*.bat     text eol=crlf
*.cmd     text eol=crlf
*.css     text 
*.java    text 
*.js      text 
*.md      text eol=crlf
*.sh      text eol=lf
*.txt     text eol=crlf
*.xml     text

However, I am finding that alternating between running git status on Cygwin or PowerShell repeatedly shows up all files as requiring modifications depending on which one I last checked them all in with.. how do I get the two to agree and obey my .gitattributes?

In response to the suggestion from @VonC

Tuesday, 2nd of April 2019, 12:32:15 PM

On Cygwin I do this:

$ git config --global core.autocrlf
false

$ echo "* text=auto" >>.gitattributes

$ git add --renormalize .

$ git commit -m "Introduce end-of-line normalization"
... snip

$ git push
... snip

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

And then in PowerShell

> git config --global core.autocrlf
false

> git status 
... snip.. every single file listed.. again!
Robert Mark Bram
  • 4,924
  • 7
  • 44
  • 65

1 Answers1

2

Make sure that, in your Cygwin environment, git config core.autocrlf is set to false

git config --global core.autocrlf false

That way, Git won't change automatically files eol, and will stick to its .gitattributes directives.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • I will try that, but why isn't my `.gitattributes` file enough to solve this? Shouldn't project specific configuration override global configuration? – Robert Mark Bram Apr 01 '19 at 20:00
  • 2
    @RobertMarkBram It should. But eol directives can be influence by that one global setting. Try, as in here (https://stackoverflow.com/a/47580886/6309) a `git add --renormalize .` (with Git 2.21+) to see if your gitattributes directives are enforced. – VonC Apr 01 '19 at 20:08