Niru
Niru

Reputation: 1577

How do I move to a forward commit?

I was testing changes in git and I checked out a previous commit:

git log

commit 223090

commit 223089

git checkout 223089

When I do a git log I do no longer see 223090.... A git status shows

HEAD detached at 223089

How can I find the actual SHA of the latest commit since it no longer shows?

Upvotes: 0

Views: 70

Answers (2)

sdferbbb
sdferbbb

Reputation: 478

Use git reflog to find the last head you were at before checking out or you could even do git checkout ORIG_HEAD.

ORIG_HEAD is a special tag to a commit, stores the original head before a command was ran.

Upvotes: 0

Niru
Niru

Reputation: 1577

Git checkout creates a new branch with HEAD at the A git branch lists all the branches, and in order to revert back I needed to stash/discard my changes and do a git checkout <branch name> in order to get back to where I was.

Upvotes: 1

Related Questions