Can't find my commit after doing a git pull
I have a local branch that I was working on last week. I knew I was going to be away for it for a while, so I committed my changes, but did not push them. Today I went back to work on it, and when I checked it out, it told me I was 40 commits behind origin, and I should do a git pull
.
So I did. And now I can't find the changes that I had committed last week. I don't have the hash of it, and I can't find it in gitk
.
I've looked at this, this, and this, but when I did a git checkout HEAD@{1}
just to see where things were, it wasn't where it should have been.
How can I find my local commit and get back to it safely?
Some time ago you made a commit, and then your HEAD pointer was referencing the commit you are currently looking for. You can use git reflog
to see a history of the commits that have been referenced by HEAD.
This history will show you all the commits referenced by HEAD, and the reason why HEAD moved to that commit. Searching this history you will find an entry like this one:
c939669 HEAD@{17}: commit: Your commit message here
At this point you have already located your commit, just need to check it out:
git checkout c939669
And you are done
链接地址: http://www.djcxy.com/p/94786.html上一篇: git命令作为hg命令
下一篇: 做完git pull后找不到我的提交