3

When I do "git status", it lists many files as modified when in reality, they are not. It shows all lines as removed, and then the same lines are added again at end of the diff report.

I can use Windiff to check that files are exactly the same. In fact, I have been using git for months without problems and today, suddenly, has appeared this problem. I did not modified most of files from months ago.

I use Windows and SourceTree, but also git command line. Both show the same problem.

The first thing I tried is to discard all. Nothing happens, the "modified" files do not disappear. Then Revert, the same. Then, I though about some kind of corruption, so I deleted .git/index file and then, "git reset". The problem is now worst, I had 30 "modified" files, now I have "1360". I checked the hard disk and it is fine.

I cannot simply to clone it again from remote since I had local branches.

By the way, other repositories I have for other projects work fine.

My first concern is to know what is happening. I am totally lost.

UPDATE

It is not a problem with \r\n lines. I did not open any file. Windiff shows no differences. Also, I removed the branch, then I checked out it from the remote repository, and the "modified" files are still there, even after discard all changes or to revert them. Also, it is not just SourceTree, I am using Git from command line.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Dabiel Kabuto
  • 2,762
  • 4
  • 29
  • 45
  • This should help you: http://stackoverflow.com/a/15967109/1257504 - seems to be a Windows/SourceTree specific issue. – Tony Barnes Apr 15 '15 at 14:08
  • Is it possible that you've opened text files that were saved on a unix system, using a Windows text editor that replaces unix line endings (`\n`) with Windows line endings (`\r\n`)? If you have unix tools around, you can use `od -c file.ext` to get a dump of the contents to know for sure, and you can use tools like `dos2unix` (available in cygwin I think) to convert things back to what git remembers. – ghoti Apr 15 '15 at 14:08
  • As @ghoti mentioned, this is most likely a line ending issue. Is the line ending type on your local git configuration set to 'auto' or are you simply accepting the line endings as the come out of the repository? Also, did you touch those files with an editor and the editor may do some tabs/spaces conversion if you resave the file? – Timo Geusch Apr 15 '15 at 14:16

3 Answers3

2

1st idea : Indentation. When you import your project in your IDE and try to re-indent it automatically, all lines could changed because of indentation.

2nd idea : End of lines. Some IDE could add a different end of line on each lines so git sees that as a difference on all line.

Hope to help you.

Fabien Dobat
  • 118
  • 8
0

Thanks Tony. I added "text=auto" and now it is solved.

As you proposed, the problem was like SourceTree App says uncommitted changes even for newly-cloned repository - what could be wrong?

However, I am confused because I changed or edited nothing in the past few months. I need to say that I installed Windows 10, maybe it could be related.

In any case, now it is solved.

Community
  • 1
  • 1
Dabiel Kabuto
  • 2,762
  • 4
  • 29
  • 45
0

Working Solution

Had the same issue my colleagues and I.

Found a solution which worked on my PC and on my peers computers.

In your git folder

Type 1 of the following commands:

$ git config core.autocrlf false
$ git config core.filemode false

(You may need to type both, but given your case the 1st one might be enough)

Bonus: If this solution worked with you and you want to do it on your entire PC (all git folders), just add the argument --global after git configure. For ex: git config --global core.autocrlf false

underflow
  • 1,545
  • 1
  • 5
  • 19