2

Started a Git repository under Ubuntu 9.10. Finally upgraded to 10.04. Current Git is 1.7.0.4.

Now when I edit a file (with gedit) that was last changed before the upgrade, then commit, the commit is full of false-positive changes, ~400 lines out of ~1400.

I use spaces to indent within my source, if that matters.

Edit: a false-positive change looks like

- var a = 1;
+ var a = 1;

Edit: problem is CR/LF changed to LF, so question becomes how to suppress these on commit? (And maybe that's not advisable?)

Liam
  • 495
  • 6
  • 21
  • What is a “false-positive change” supposed to be? – Bombe Sep 03 '11 at 20:43
  • 1
    Check for whitespace (http://stackoverflow.com/questions/5257553/coloring-white-space-in-git-diffs-output) or line endings (http://stackoverflow.com/questions/3920650/git-diff-show-me-line-ending-changes) changes. – Benoit Garret Sep 03 '11 at 22:03
  • Thanks, see new Edit on the Q. – Liam Sep 03 '11 at 22:33
  • 1
    Are you working with windows developers? CR/LF is for windows, LF for linux. It's a bit strange that your repo used CR/LF. – Benoit Garret Sep 03 '11 at 22:49
  • Perhaps Gedit was using CR/LF in Javascript files, and its latest version doesn't? – Liam Sep 03 '11 at 23:12

2 Answers2

1

If Git shows these lines as changed, something has changed. If you can’t see what has changed, it’s probably (in) the whitespace. Try viewing the diff in a hexdump (git diff|hexdump -C), this should show the differences a lot better.

Bombe
  • 81,643
  • 20
  • 123
  • 127
  • `git diff `, `git diff --help` for more information, `git diff` has lots of options. `HEAD` is the most recent commit, `HEAD~` (or `HEAD~1`) would be its parent. – Bombe Sep 03 '11 at 22:13
0

Check the GitHub help on the subject.

In your case, that would be setting this config value:

$ git config --global core.autocrlf input

This will convert everything to LF when committing. It may cause problems if your repository is expected to be in CR/LF.

If you're using Gedit, this plugin would be nice to have in your case.

Benoit Garret
  • 14,027
  • 4
  • 59
  • 64