开发者

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜