How to Pull a Remote Branch in Git

Published Sep 24, 2021

Suppose we’d like a pull a remote branch from a repository that doesn’t exist on our local machine.

1. Fetch Remote Branch

First, we would have to fetch the remote branch.

We can either fetch all remote branches for the repository, or just that specific branch.

git fetch --all # Fetch all branches
git fetch origin branchName # Fetch this one branch

2. Checkout/Switch to Branch

Then, we can simply checkout, or switch, to the branch.

git checkout branchName # Move to branch
git switch branchName # Another way to move to branch

More CLI Articles