Undo “git checkout HEAD foo.c” in git scm
I did checkout a file with my latest changes to HEAD by mistake..
git checkout HEAD foo.c
that means i lost all my changes that i wanted to commit…
is there a way to find these changes in git cache or in some local history?
2 Solutions collect form web for “Undo “git checkout HEAD foo.c” in git scm”
if you have not stashed changes to the file while working (and then restoring them) then there’s little you can do about it.
if you have added the changes of the file using
git add (you probably have, because you were about to commit), then the blob should already be in git’s db. you can use
git fsck to find dangling objects. look for blobs and inspect all of them – either using
git show or
git cat-file – (it takes time, i know …), but if you are lucky you will find the contents of your file. use
git cat-file blob $hash_of_object > foo.c do to recover the content of your file
Unless you have committed it, (or stashed it or added it to index) git wouldn’t know about your local changes. So, no.