Alexander Mills Alexander Mills - 1 month ago 14
Git Question

How to checkout the newest commit (tip of a branch)

Say I am on the tip of the Git graph and I am on the "latest" commit, let's call it commit-x. Say I checkout an older git commit with with

git checkout <commit-old>

After doing that, is there a way to checkout the latest commit again (commit-x), without having to know what commit-x is?

In other words, how can I checkout the tip of a Git branch automatically?

Answer Source

git checkout branch-name is exactly what this does.