SeekingAlpha
SeekingAlpha

Reputation: 7807

Git: Move head one commit ahead

I did a git reset HEAD~1 to go back one commit. I did this a number of times.

I now want to go back to where HEAD was originally but am not sure how to move my HEAD forward.

Does anyone know what command I need to use?

1-2-3-4-5-6

Originally I was at 6 and I reset back to 3. I now want to go back to 5. My understanding is that since I did not do git reset --hard my original files from commit 6 is still available. Theoretically I should be able to un-reset and move back up correct?

Upvotes: 38

Views: 33888

Answers (1)

user3159253
user3159253

Reputation: 17455

use git reflog to see SHA-1 of last operations and then do git reset --hard <sha1>.

Git keeps objects (and their SHA-1 respectively) even they go "out of scope" until next git gc invocation. So if you think, you've lost something in the project history, use git reflog to see if that smth is there.

Upvotes: 49

Related Questions