2

I'm facing a strange situation with git . I just have edited several lines in a long file but then when I went to commit changes ,I saw that git just highlighted the whole file content with a red color . what is wrong ?

I'm using git's windows GUI

Edit : one thing I remember now is that I added .csproj to the gitignore list in last commit . does this has any effect on this ?

Update : the problem as friends suggested was from line ending . I solved it using this question's answer

Community
  • 1
  • 1
mohsen dorparasti
  • 8,107
  • 7
  • 41
  • 61

2 Answers2

8

The problem was because of line ending .

git config core.autocrlf was set to true . I used solutions mentioned in this 2 posts

Dealing with line endings

Trying to fix line-endings with git filter-branch, but having no luck

and set it as false . and it is solved.

Community
  • 1
  • 1
mohsen dorparasti
  • 8,107
  • 7
  • 41
  • 61
0

We had the same problem in Visual Studio 2015 (vs2015) on Windows with files that we had edited but un-done all edits.

The only thing I would add to the other answer and what we ended up doing is to try editing the .gitattributes at the root of your solution by commenting out

* text=auto

to be

#* text=auto

According to this article, this entry overrides the git config so even if you remove the other entry in the git config the problem could still occur.

Commenting the .gitattributes removed the fake edits and uncommenting it added the fake edits back in for us.

Where this answer originally came from: Files showing as modified directly after git clone

Community
  • 1
  • 1
user1568891
  • 386
  • 6
  • 12