5

I did some work on a project on one machine, then pushed to github and, on another machine, cloned and did some work, then pushed. Then I went back to the first machine and did a pull. Now the first machine thinks all the files that were in the project originally were changed. I've tried

git checkout -f --

and

git rm --cached -r .
git checkout -f

and even tried

git stash

but no matter what I do, git status tells me those files have been changed. How do I make it stop?

Dan
  • 12,409
  • 3
  • 50
  • 87
  • 1
    What's the file system you use underneath? This is relevant because FAT has less precision. – 0xC0000022L Jun 05 '12 at 01:25
  • 1
    Did the files *actually* change? Perhaps you've got line-ending issues. Is the Github repository public so we can help? – Greg Hewgill Jun 05 '12 at 01:33
  • Have you run `git diff` on any of the "changed" files? – Ilion Jun 05 '12 at 07:58
  • NTFS. git diff says the whole file is different. and even if it's a line ending issue, shouldn't `checkout -f` fix that? – Dan Jun 06 '12 at 16:21
  • 2
    Like Greg said it's probably a line ending issue. `checkout -f` is *not* enough to fix that, unfortunately. After changes to the `core.autocrlf` setting you need to run `rm .git/index` and `git reset --hard` to make them effective. Note that the latter command will get rid of any uncommitted changes, so be sure your working tree is clean before you do that. – sschuberth Jun 29 '12 at 07:51
  • In my case, I've used Beyond Compare to diff the file in hex mode, and not a single byte is different. This is so very annoying. – Umar Farooq Khawaja Apr 24 '14 at 10:11
  • @UmarFarooqKhawaja I believe it happened the same way for me. Szeremi Attila's answer should work. – Dan Apr 24 '14 at 12:41
  • I tried that to no avail. I am beginning to think git really sucks :( – Umar Farooq Khawaja Apr 24 '14 at 13:24
  • @UmarFarooqKhawaja If you don't have changes you need, try deleting the entire local repo and re-cloning. – Dan Apr 24 '14 at 13:31
  • @Dan, unfortunately, I can't do that because I have some local branches that I don't want to push out. I keep my development in these before merging them into the master. The only solution I can think of is to commit the changes and then destroy the commit without putting the changes from the commit back into the tree. See [this question of mine](http://stackoverflow.com/questions/23266990/can-someone-explain-to-me-what-difference-git-diff-is-seeing-here) – Umar Farooq Khawaja Apr 24 '14 at 13:53

1 Answers1

6

This seems to be a line-ending/autocrlf issue. A great trick I realized for fixing this (if your index doesn't matter) is:

$ git add -u .
$ git reset .
Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64