tags:

views:

560

answers:

3

Hi, I'm running into a recurrent problem with git on windows (I'm running MSysGit from package Git-1.6.0.2-preview20080923.exe, i tried as well with Git-1.5.6.1-preview20080701.exe and the results are the same).

It happens very offen that some files are shown as changed when I didn't change them, and in git-gui it shows that the content removed is the same as the content added (usually it's the whole file), i.e.
- This line was here before
- This line was here before as well
- and this line too...
+ This line was here before
+ This line was here before as well
+ and this line too...

I tried with git checkout -f and git reset --hard, but the files remain the same. I tried deleting the files prior to the hard reset as well. I tried googling for it but couldn't find anything related.
Can you tell me how to sort this out, or what steps would you take to confirm that it's a problem with Git and not my system, so I can report it as a bug.

+5  A: 

You may have line-ending problems, if you haven't handled that either in your text editor or in the Git configuration.

To solve this in Git, set the autocrlf option in the Git config file:

$ git config --global core.autocrlf true

This causes git to convert the newlines to the system’s standard when checking out files, and to LF newlines when committing in. Then you will need to checkout a fresh working copy, which will filter the line endings according to the autocrlf setting.

$ git reset --hard HEAD
$ git commit -a

This commits any files that are changed by standardizing the line endings, so now your repo is consistent and you won't generate more line ending problems.

Paul
I'd give +1000 if I could
Frederic Morin
A: 

If you are using Visual Studio then it is probably visual studio converting tabs into spaces (#@%$#). You can turn this "feature" off somewhere in the visual studio settings. You can also set git up to not check for whitespace changes, but I cannot recommend that.

The suggestion above setting autocrlf could work, but it is default set to true in the version of Git you are using.

A: 

In VS2008, the setting for converting tabs to spaces is Tools -> Options -> Text Editor -> -> Tabs, where you select the radio button at the buttom of the window.

ben f.