tags:

views:

280

answers:

3

I'm in master and I do a git pull, I get a message indicating I need to pull a remote branch.

Typically I do a git co [branch] then git pull/rebase.

Is there a way to git pull/rebase of [branch] without having to do a git co [branch] first?

A: 

git pull origin branch

Sorry, forgot to mention that pull merges.

If you can use git fetch origin branch to just fetch that branch. http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html

Andrei Serdeliuc
This appears to try to merge the branch with master.
Scott
A: 

I don't think there is any way to do an operation on a branch without switching to it. But you can combine the pull and rebase by doing git pull --rebase origin

Jeremy Wall
Aye. I'm lazy, so I just set the rebase=true option for the branch in my .git/config.
Scott
+1  A: 

If you combine Apikot and Jeremy you get:

git pull --rebase origin branch

Or, if you haven't set the branch mapping up in your config:

git pull --rebase origin <src>:<dst>
Henrik Gustafsson