Problem with debugging with Git on windows (MsysGit)

I have a problem with git on Windows (I run MSysGit from the Git -1.6.0.2-preview20080923.exe package, I also tried using Git -1.5.6.1- preview20080701.exe and the results are the same).

It often happens that some files are displayed as modified when I did not change them, and in Git-gui it shows that the deleted content is the same as the added content (usually 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 remained the same. I tried deleting files before hard reset. I tried looking for him, but could not find anything related.
Can you tell me how to figure this out, or what steps you will take to confirm that this is a problem with git and not with my system, so I can report it as an error.

+4
source share
3 answers

You may have problems with line endings if you didn't handle this in either a text editor or Git configuration.

To solve this problem in Git, set the autocrlf parameter in the Git configuration file:

 $ git config --global core.autocrlf true 

This causes Git to convert newline characters to the system standard when checking files and to LF lines when committing. Then you will need to check the new working copy, which will filter the end of the line according to the autocrlf setting.

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

This captures any files that are modified by standardizing line endings, so now your repo is consistent and you will not generate more line ending problems.

+5
source

If you use Visual Studio, then probably visual studios convert tabs to spaces (# @% $ #). You can disable this "feature" somewhere in the settings of the visual studio. You can also install git to not check for whitespace changes, but I cannot recommend this.

The above autocrlf definition may work, but by default it is set to true in the git version that you are using.

0
source

In VS2008, the option to convert tabs to spaces is Tools → Options → Text Editor → -> Tabs, where you select the radio button at the bottom of the window.

0
source

All Articles