How to Pull a Remote Branch in Git

Published Sep 24, 2021  ∙  Updated May 2, 2022

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

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