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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With