Sunday, April 17, 2011

how do I pull a remote tracking branch while in the master branch

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?

From stackoverflow
  • 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

    Scott : This appears to try to merge the branch with master.
  • 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

    Scott : Aye. I'm lazy, so I just set the rebase=true option for the branch in my .git/config.
  • 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>
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.