Maciek Sitkowski
Maciek's Blog

Follow

Maciek's Blog

Follow

How to checkout recent branch in git?

Maciek Sitkowski's photo
Maciek Sitkowski
·Nov 7, 2022·

1 min read

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


 
Share this