The Cook The Cook - 1 year ago 78
Git Question

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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download