Pull A Git Branch from Remote
Up until lately I have been improperly pulling my remote branches to local. What I mean is I create a new branch locally, push it to remote (GitHub) then pull it onto a designers computer with the following command
(this is not how to do it)
#DON’T DO THIS
git checkout -b < new_branch >
git pull origin < new_branch >
git checkout -b < new_branch >
git pull origin < new_branch >
Instead do
git checkout -b < new_branch > origin/< new_branch >
So real world example would be
git checkout -b newdesign origin/newdesign
Obviously ‘newdesign’ is the branch name.
UPDATE:
If you have trouble doing this with an error
fatal: git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout ‘origin/‘ which can not be resolved as commit?’
Did you intend to checkout ‘origin/
Then try a git pull first.
git pull
Related Posts
Posted on July 22, 2009 at 1:56 pm by Jordan Carter · Permalink
In: Uncategorized · Tagged with: checkout, git, Pull, Remote Branch
In: Uncategorized · Tagged with: checkout, git, Pull, Remote Branch


on July 28, 2009 at 2:13 am
Permalink
I don’t understand why the latter is preferred. They appear to do the same thing.
on March 29, 2010 at 1:24 pm
Permalink
Thanks,
This help me
on December 10, 2010 at 1:51 am
Permalink
best not use angled brackets as placeholders when you explain shell commands.
on April 2, 2011 at 1:57 am
Permalink
Thanks for the update. I got used to git pull *origin branch_name* and couldn’t figure out why I was unable checkout my new remote branch.
git pull, even though it gives me a warning, does the first step of pulling new branch names.
on April 7, 2011 at 2:11 am
Permalink
thanks, this was the only way I got this working. Sweating real bad now.
on August 29, 2011 at 6:58 pm
Permalink
Thanks a lot. Do you know how to repull the latest branch?
on December 9, 2011 at 5:29 am
Permalink
@max
git pull doesn’t just that