Last Updated: October 04, 2020
·
42.34K
· fr0gs

git checkout remote branch

In your workflow you'll often need to checkout and fetch branches from a remote repository to do code review of your colleagues for example.

Usage:

git checkout -b <local-branch> <remote-branch>
git fetch

So for example I have a branch called feature/abc remotely

git checkout -b feature/abc origin/feature/abc

There is also a shortcut for this command:

git checkout --track -b <remote-branch>

Related protips:

Remove all your local git branches but keep master