2

I have 2 branches (master and dev). Another worker has pushed a new branch called stage into the repository so that stage is now 1 commit ahead of master. I am trying to pull down stage so that I can merge it into master (and thus merge into dev), but I am having issues pulling down stage. How do I pull down a clean version of stage?

Aram Papazian
  • 2,453
  • 6
  • 38
  • 45

2 Answers2

3

I don't think you understand the branching basics of Git here. You may understand a bit more after reading my answer, by example.

the long story

You should fetch all updates

git fetch --all

then you should see the now still remote branch:

git branch -a
[...]
remotes/origin/stage

Optionally, you can make this branch a local branch stage (does not have to have the same name) by checking it out

git checkout -b stage origin/stage

And you should be switched onto this branch with this.

Now back to master and merge it:

git checkout master
git merge origin/stage # or just 'stage' if you have it local

the pull magic

Now, one could combine both fetch and merge steps by a single pull. However, sometimes it's needed to fetch new branches and their heads in order to be able to specify them.

git pull origin stage
gertvdijk
  • 24,056
  • 6
  • 41
  • 67
0

This should work:

git checkout master
git pull origin stage

Considering master isn't linked to stage at all, you need to specify from where you are pulling, and what you are merging.
See:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • origin/stage , tried to add as an edit, but apparently 6 characters are needed to fix a syntax issue. – sjakubowski Dec 15 '12 at 00:31
  • @sjakubowski `git pull origin stage` is like `git pull origin master:stage` here: it merges the remote branch `stage` in the current branch, as shown in the example section of `git pull`: http://git-scm.com/docs/git-pull#_examples – VonC Dec 15 '12 at 00:37