7

My autocrlf is equal to true. In my cygwin-shell git status gives me a correct list of all my changes.

In Git Bash git status says I modified all files in the project. I also see this in Git GUI and the Changes-tab in IntelliJ.

How is this possible, and more importantly, how can I fix it?

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
Arthur C
  • 1,274
  • 1
  • 14
  • 34

1 Answers1

6

Cygwin Git "sees the world" as if it runs on a POSIX platform—thanks to the emulation provided by Cygwin. Contrary to this, Git for Windows is a native Windows program which does not use any emulation and tries to be as close to Windows standards (however idiotic) as possible. What this leads to is that for Cygwin Git, LF is the standard EOL character, while for Git for Windows, the native EOL sequence is CRLF. So both tools see the world differently, and that explains what you observe. Please read this recent thread for more info (and especially this message).

In either case, consider setting core.autocrlf to false anyway to avoid headaches bound to this "magic". I'm using GfW solely, and in the end switched that setting to false (it defaults to true) for good.

You might also find the extremely well commented .gitattributes file from the Mono project to be interesting to study.

Community
  • 1
  • 1
kostix
  • 51,517
  • 14
  • 93
  • 176
  • Ok, thanks! Several questions: (1) So you suggest setting autocrlf to false? (2) Any idea if there's somehow a way to have a GUI representation of git using cygwin? I sometimes have to do complex stages/commits where adding all modified files is not an option. – Arthur C Oct 16 '14 at 21:44
  • @ArthurC, sorry for the long delay. 1) Yes, switching it to false will turn off any magic related to EOL sequences which should make Gits on both sides have the same idea w.r.t. EOLs. You then could force using CRLFs for certain (or all) files via `.gitattributes`. Or, if possible, make sure you're using text editors which have no problems with sole LFs as EOLs (Emacs and Vim are two examples). 2) I beleive Cygwin has builds of Tcl/Tk and hence stock Git's GUI tools, `gitk` and `git gui` should be available there. – kostix Oct 19 '14 at 15:09
  • @ArthurC, 2), continued. Note that it's perfectly possible to do fine-grained staging using command-line tools only: `git add` can be used to stage any selected file, and `git add --patch` can be used to stage selected *hunks* of the changes that would be staged if you would do unadorned `git add`. The changes can also be selectively undone via `git reset --patch` and `git checkout --patch`: the former unstages the changes from the index while the latter does the same to the work tree. Not that I advise you against using `git gui` et al, just showing they do nothing special plain Git can't. – kostix Oct 19 '14 at 15:13
  • Thanks kostix, but I'm taking another route. Uninstalled every git on my machine, installed msysgit and autocrlf=true. My problems are gone. A gui is handy for me because if I have 70 files I want to commit and 9 not, doing manually git add is really not efficient. – Arthur C Oct 25 '14 at 09:56