w1ng
w1ng

Reputation: 324

git checkout newer branch

I switched to a older commit with: git checkout $HASH to look for something i did in an older version of my directory. Now i want to go back to the newest commit, but i cant find the Hash for that anymore? when i do a git log it just shows the older commits from the commit i am currently at. How can i switch to the newest commit again?

Upvotes: 2

Views: 467

Answers (2)

Fred Foo
Fred Foo

Reputation: 363467

git checkout <branch>, e.g. git checkout master.

Upvotes: 3

Adam Byrtek
Adam Byrtek

Reputation: 12202

Use the name of the branch on which you worked before

git checkout [branch]

If for some reason you don't know the name, you can find the previous position in the reflog

git reflog

It gives you a list of commits on which you worked in the past, where the first position is the most recent one.

Upvotes: 2

Related Questions