Aram Papazian
Aram Papazian

Reputation: 2539

git merge pull branches confusion

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?

Upvotes: 2

Views: 194

Answers (2)

gertvdijk
gertvdijk

Reputation: 24844

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

Upvotes: 3

VonC
VonC

Reputation: 1323973

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:

Upvotes: 0

Related Questions