The Cook The Cook - 1 month ago 9
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

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