Update: Using Git Switch

All of the information written below was accurate, but a new command, git switch has been added that simplifies the effort.

If daves_branch exists on the remote repository, but not on your local branch, you can simply type:

git fetch --all
git switch daves_branch

Since you do not have the branch locally, this will automatically make switch look on the remote repo. It will then also automatically set up remote branch tracking.

Original Post

You need to create a local branch that tracks a remote branch. The following command will create a local branch named daves_branch, tracking the remote branch origin/daves_branch. When you push your changes the remote branch will be updated.

For most recent versions of Git:

git checkout --track origin/daves_branch

--track is shorthand for git checkout -b [branch] [remotename]/[branch] where [remotename] is origin in this case and [branch] is twice the same, daves_branch in this case.

For Git 1.5.6.5 you needed this:

git checkout --track -b daves_branch origin/daves_branch

For Git 1.7.2.3 and higher, this is enough (it might have started earlier, but this is the earliest confirmation I could find quickly):

git checkout daves_branch

Note that with recent Git versions, this command will not create a local branch and will put you in a 'detached HEAD' state. If you want a local branch, use the --track option.

Full details are here: 3.5 Git Branching - Remote Branches, Tracking Branches

Answer from ralphtheninja on Stack Overflow
Top answer
1 of 16
4360

Update: Using Git Switch

All of the information written below was accurate, but a new command, git switch has been added that simplifies the effort.

If daves_branch exists on the remote repository, but not on your local branch, you can simply type:

git fetch --all
git switch daves_branch

Since you do not have the branch locally, this will automatically make switch look on the remote repo. It will then also automatically set up remote branch tracking.

Original Post

You need to create a local branch that tracks a remote branch. The following command will create a local branch named daves_branch, tracking the remote branch origin/daves_branch. When you push your changes the remote branch will be updated.

For most recent versions of Git:

git checkout --track origin/daves_branch

--track is shorthand for git checkout -b [branch] [remotename]/[branch] where [remotename] is origin in this case and [branch] is twice the same, daves_branch in this case.

For Git 1.5.6.5 you needed this:

git checkout --track -b daves_branch origin/daves_branch

For Git 1.7.2.3 and higher, this is enough (it might have started earlier, but this is the earliest confirmation I could find quickly):

git checkout daves_branch

Note that with recent Git versions, this command will not create a local branch and will put you in a 'detached HEAD' state. If you want a local branch, use the --track option.

Full details are here: 3.5 Git Branching - Remote Branches, Tracking Branches

2 of 16
1333

I have used fetch followed by checkout...

git fetch <remote> <rbranch>:<lbranch>
git checkout <lbranch>

...where <rbranch> is the remote branch or source ref and <lbranch> is the as yet non-existent local branch or destination ref you want to track and which you probably want to name the same as the remote branch or source ref. This is explained under options in the explanation of <refspec>.

Bash is so smart it auto completes the first command if I tab after the first few letters of the remote branch. That is, I don't even have to name the local branch; Bash automatically copies the name of the remote branch for me. Thanks, Bash!

Also as the answer in this similar Stack Overflow post shows, if you don't name the local branch in fetch, you can still create it when you check it out by using the -b flag. That is, git fetch <remote> <branch> followed by git checkout -b <branch> <remote>/<branch> does exactly the same as my initial answer. And evidently, if your repository has only one remote, then you can just do git checkout <branch> after fetch and it will create a local branch for you. For example, you just cloned a repository and want to check out additional branches from the remote.

I believe that some of the documentation for fetch may have been copied verbatim from pull. In particular the section on <refspec> in options is the same. However, I do not believe that fetch will ever merge, so that if you leave the destination side of the colon empty, fetch should do nothing.

NOTE: git fetch <remote> <refspec> is short for git fetch <remote> <refspec>: which would therefore do nothing, but git fetch <remote> <tag> is the same as git fetch <remote> <tag>:<tag> which should copy the remote <tag> locally.

I guess this is only helpful if you want to copy a remote branch locally, but not necessarily check it out right away. Otherwise, I now would use the accepted answer, which is explained in detail in the first section of the checkout description and later in the options section under the explanation of --track, since it's a one-liner. Well... sort of a one-liner, because you would still have to run git fetch <remote> first.

FYI: The order of the <refspecs> (source:destination) explains the bizarre pre Git 1.7 method for deleting remote branches. That is, push nothing into the destination refspec.

🌐
GeeksforGeeks
geeksforgeeks.org › git › git-pull-remote-branch
Git Pull Remote Branch - GeeksforGeeks
February 26, 2026 - Common commands to sync local branches with remote changes and manage remote branches. git pull <remote> <branch>: Fetches changes from the specified remote branch and merges them into your current branch.
Discussions

How do you update your local branch?
I generally do git pull, but I have my environment configured to default to rebase and not merge. More on reddit.com
🌐 r/git
10
0
September 18, 2024
git clone gives `WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!`
I think you've run into an issue when GitHub changed its public key some time ago - https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/ More on reddit.com
🌐 r/github
9
0
July 14, 2023
Is It Acceptable to Rename a Git Branch I Created?
It depends on your teams wokflow. In my situation I rename branches all the time. My coworkers and don't really share branches and so there isn't anyone affected by me changing a branch name. More on reddit.com
🌐 r/git
7
5
July 13, 2023
Discard all changes made to a file in a branch
You can use git checkout -- path/from/repo/root/to/yarn.lock . For example, if yarn.lock is in the root of your repo and you want to restore it to the commit beginning with 123abc, you can git checkout 123abc -- yarn.lock then when you commit the file, it should be in the same state it was as of commit 123abc. Note that the diff won't show the changes (when they hit "compare"), but the history will show whatever intermediate states the file went through unless you're doing something that rewrites the history, such as rebasing or squashing. More on reddit.com
🌐 r/git
27
8
May 9, 2021
People also ask

How do I pull a specific remote branch?
Run git pull origin . 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.
🌐
coddy.tech
coddy.tech › git commands › remotes › git pull remote branch
Git Pull Remote Branch - Pull a Specific Branch | Coddy
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 - modern Git automatically creates a local branch tracking origin/. After that, a plain git pull keeps it up to date.
🌐
coddy.tech
coddy.tech › git commands › remotes › git pull remote branch
Git Pull Remote Branch - Pull a Specific Branch | Coddy
How do I pull with rebase instead of merge?
Add --rebase: git pull origin --rebase fetches the branch and replays your local commits on top of it, keeping history linear instead of creating a merge commit.
🌐
coddy.tech
coddy.tech › git commands › remotes › git pull remote branch
Git Pull Remote Branch - Pull a Specific Branch | Coddy
🌐
Graphite
graphite.com › guides › git-pull-remote-branches
Git pull remote branches
Can be thought of as a collection of commits. Fetch: The command git fetch downloads branches and their respective commits from the remote repository but doesn't merge them into your current working files.
🌐
Git
git-scm.com › book › en › v2 › Git-Branching-Remote-Branches
Git - Remote Branches
If you have a tracking branch set ... for you by the clone or checkout commands, git pull will look up what server and branch your current branch is tracking, fetch from that server and then try to merge in that remote branch....
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › git-pull-remote-branch-how-to-fetch-remote-branches-in-git
Git Pull Remote Branch – How To Fetch Remote Branches in Git
November 7, 2024 - If you want to fetch remote branches and merge them with your work or modify your current work, you can use the git pull command.
🌐
Git
git-scm.com › docs › git-pull
Git - git-pull Documentation
Integrate changes from a remote repository into the current branch. First, git pull runs git fetch with the same arguments (excluding merge options) to fetch remote branch(es). Then it decides which remote branch to integrate: if you run git pull with no arguments this defaults to the upstream ...
🌐
Coddy.Tech
coddy.tech › git commands › remotes › git pull remote branch
Git Pull Remote Branch - Pull a Specific Branch | Coddy
3 weeks ago - 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.
🌐
LogRocket
blog.logrocket.com › home › how to check out a remote branch in git: a step-by-step guide
How to check out a remote branch in Git: A step-by-step guide - LogRocket Blog
March 13, 2025 - To avoid that unnecessary headache, git fetch first, then git checkout -b <branch name> Under the hood, we have git pull as a shortcut for git fetch, followed by git merge. So, git fetch downloads all the commits or changes from the remote ...
🌐
CodeSignal
codesignal.com › learn › courses › working-with-remote-repositories › lessons › git-fetch-and-pull-managing-remote-changes-and-resolving-conflicts
Git Fetch and Pull: Managing Remote Changes and ...
This command first fetches changes from the main branch on the remote repository and then merges them into your current local branch (which is typically also main). Using git pull is convenient when you want to synchronize your local branch with the remote branch quickly, incorporating any ...
🌐
Sentry
sentry.io › sentry answers › git › fetch a remote branch in git
Fetch a remote branch in Git | Sentry
June 15, 2023 - We can do this using git fetch to retrieve the remote branch and git switch to work on it locally. First, fetch the remote branch: ... Under the hood, this command will create a local branch named remote-branch, which tracks the version of ...
🌐
Atlassian
atlassian.com › git › tutorials › syncing › git pull
How to Pull a Git Repository? | Atlassian Git Tutorial
The git pull command is actually a combination of two other commands, git fetch followed by git merge. In the first stage of operation git pull will execute a git fetch scoped to the local branch ...
🌐
W3Schools
w3schools.com › git › git_branch_pull_from_remote.asp
Git Pull Branch from Remote
git branch -a * master remotes/origin/html-skeleton remotes/origin/master
🌐
GitHub
gist.github.com › grimzy › a1d3aae40412634df29cf86bb74a6f72
Git pull all remote branches · GitHub
git branch -r | grep -v '->' | tr -d 'origin/' | while read remote; do echo "parsing branch $remote"; git checkout "$remote"; git reset --hard $remote ; git pull; echo "$remote done";done
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › git pull remote branch
Git Pull Remote Branch | Learn how to pull from a remote branch in Git
November 14, 2022 - Learn how to use Git pull remote branch to pull changes from a remote Git branch. Plus, see why Git pull origin main is one of the most common examples of this command.
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › version-control › git-fetch-pull-sync
git fetch, pull, push, & sync - Visual Studio (Windows) | Microsoft Learn
Fetching checks if there are any remote commits that you should incorporate into your local changes. If you see any, pull first to prevent any upstream merge conflicts. When you fetch a branch, the Git Changes window has an indicator under the branch drop-down, which displays the number of unpulled commits from the remote branch.
🌐
CloudBees
cloudbees.com › blog › git-pull-how-it-works-with-detailed-examples
Git Pull: How It Works With Detailed Examples
July 9, 2021 - Now let’s simulate another user collaborating to the same remote. Using the command line, go to a different folder and clone the repository, using the GitHub URL: ... echo hi > file4 && git add . && git commit -m "Add fourth file"echo hi > file5 && git add . && git commit -m "Add fifth file"git push · Now you’re finally ready to use git pull! Go to the folder in which you cloned the repository. First, run the following command: ... With the command above, you fetch changes from the branch main in the remote called origin.
🌐
GitHub
github.com › git-guides › git-pull
Git Guides - git pull · GitHub
To force Git to overwrite your current branch to match the remote tracking branch, read below about using git reset. git pull --all: Fetch all remotes – this is handy if you are working on a fork or in another use case with multiple remotes.
🌐
DEV Community
dev.to › delightfullynerdy › pull-remote-branches-2c6e
Pull remote branches - DEV Community
January 11, 2021 - Type git checkout -b branchName origin/branchName - Replace branchName with the name of the remote branch you wish to pull