3229

The remote repository contains various branches such as origin/daves_branch:

$ git branch -r origin/HEAD -> origin/master origin/daves_branch origin/master 

How do I switch to daves_branch in the local repository so that it tracks origin/daves_branch?

I tried:

$ git fetch origin daves_branch $ git checkout daves_branch 
9

31 Answers 31

1
2
-2
git checkout -b branch_name git pull remote_name branch_name 
Sign up to request clarification or add additional context in comments.

3 Comments

While this snippet might answer the question, it's better to include some explanation about what it does and how it differs from the very large number of answers already here.
I personally do not like this option. Because in case you are creating a new branch from Master and then pulling data from remote branch, that remote branch may or may not be on the same page as the master and might invite some unnecessary code updates
Some explanation would be in order.
1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.