Skip to main content

How to checkout recent branch in git?

Published 1 min readMarkdown
Part of seriesToday I Learned

Use the following command to checkout recent branch:

git checkout -

It's basically an alias for:

git checkout @{-1}

You can checkout any previous branch, by replacing N with the N-th last branch that was checked out.

git checkout @{-N}

Following diagram (source), illustrates it perfectly:

git-checkout-recent-branch.jpg


No comments yet. Be the first to comment.

More from this blog