Git: How to revert 2 files that are stubbornly stuck at "Changed but not committed"?
I spent hours trying to solve a similar issue - a remote branch that I had checked out, which stubbornly showed four files as 'Changed but not updated', even when deleting all files and running git checkout -f
again (or other variations from this post)!
These four files were necessary, but certainly hadn't been modified by me. My final solution - persuade Git that they had not been changed. The following works for all checked out files, showing 'modified' status - make sure you have already committed/stashed any that have really been modified!:
git ls-files -m | xargs -i git update-index --assume-unchanged "{}"
On Mac OSX, however xargs operates a little bit different (thx Daniel for the comment):
git ls-files -m | xargs -I {} git update-index --assume-unchanged {}
I've added this as a placeholder for myself for next time, but I hope it helps someone else too.
-Al
What are the line endings in the files? I'm betting they're CRLF. If they are, check out this guide: http://help.github.com/line-endings/
In short, you need to make sure git is set to convert the line endings to LF on commit, and then commit those files. Files in the repo should always be LF, files checked out should be the OS's native, assuming you set git correctly.
this is how I fixed the same problem in my case: open .gitattributes change:
* text=auto
to:
#* text=auto
save and close , then revert or reset, thanks to @Simon East for the hint