How to access a previous version and then go back to the latest git checkout


The question is simple: Imagine that I have 10 versions. I used git checkout on Friday to quickly parse a row.

How can I go back to the latest version if her id is missing from my git log ? How can I use git checkout for the most current without knowing her id since the sixth is my "current HEAD ".

Thank you very much for your attention.


If you went to a specific commit and want to go back to the branch's most recent commit, just checkout the branch again:

git checkout 123456 # hash de um commit específico
git checkout nome_branch # vai para o commit mais recente da branch

If you want to go back to the previous checkout (and not the most recent commit), you can use:

git checkout -

It works similarly to cd - on Linux, going back to the directory you were in earlier.

Scroll to Top