Menu
Coddy logo textTech

Git: Pull a Remote Branch

Last updated

To pull changes from a specific remote branch, name the remote and branch: git pull origin <branch>. This fetches that branch and merges it into your current one. If you want the remote branch as its own local branch, fetch first and check it out - see the examples below.

Try these in the terminal playground - a real shell in your browser, nothing to install.

git pull origin <branch> fetches that specific remote branch and merges it into the branch you are on.

Syntax

CommandWhat it does
git pull origin mainPull main from origin into the current branch
git pull origin feature --rebasePull a branch and rebase instead of merge
git fetch originDownload all remote branches (no merge)
git switch featureCheck out a fetched remote branch locally

Pull a branch you don't have locally

Fetch it, then create a local branch that tracks it.

StepCommandResult
1git fetch originDownload the remote's branches
2git switch featureCreate a local feature tracking origin/feature
3git pullNow a plain pull keeps it up to date

Git pull remote branch FAQ

How do I pull a specific remote branch?
Run git pull origin <branch>. This fetches the named branch from the origin remote and merges it into whatever branch you currently have checked out. To pull it into a matching local branch instead, switch to that branch first, then run git pull.
How do I pull a remote branch that I don't have locally?
Run git fetch origin to download the remote's branches, then git switch <branch> - modern Git automatically creates a local branch tracking origin/<branch>. After that, a plain git pull keeps it up to date.
What's the difference between pulling into the current branch and a new one?
git pull origin <branch> merges the remote branch into your current branch, mixing their histories - useful for bringing changes in. If you instead want the remote branch on its own, fetch and switch to it so it becomes a separate local branch that tracks the remote.
How do I pull with rebase instead of merge?
Add --rebase: git pull origin <branch> --rebase fetches the branch and replays your local commits on top of it, keeping history linear instead of creating a merge commit.
Can I practice this online?
Yes. Open the terminal playground to run git pull in a real shell in your browser - nothing to install. Coddy's free interactive Git course also covers working with remotes step by step.
Coddy programming languages illustration

Learn Git with Coddy

GET STARTED