How to return back to unpushed commits after returning back to an earlier commit

I commited my code, but did not push it. Let's call this commit #5 Later I needed to try an earlier version. So I checkout commit #3. Now I want to get back to my commit #5. How do I find out its commit id, and return to it?

Tried -git log, but it only shows commits from #3 to #1.


You can use this method to make HEAD re-point to commit #5, just run this command:

git checkout branch_name

After that, refer to lvan's comment to run this command to the see log:

git log --oneline --decorate --graph --all

You will find it will move the head to the latest commit #5

链接地址: http://www.djcxy.com/p/3966.html

上一篇: 如何在Git中修改master(在这种情况下)

下一篇: 如何在返回到先前的提交后返回到unpushed提交