1

I have two branches on my local, i.e. master and foo. I recently took a pull from origin and updated my master branch. Now I want to merge those changes into the branch foo and then commit and push those changes in that branch itself?

How to do I do that?

I can't seem to wrap my head around the merge command.

1 Answer 1

3

It should be as simple as:

git checkout foo git merge master 

But that will merge all commits since foo started from master (or at least since master was last merged into foo: see git merge-base)

 (new commits after git pull) vvvv x--x--x--x--X--X (master, origin/master) \ f--f--f (foo) 

Merges into

 (ALL those commits are merged in foo: x as well as X) vvvvvvvvvv x--x--x--x--X--X (master, origin/master) \ \ f--f--f -----M (foo) 
Sign up to request clarification or add additional context in comments.

3 Comments

and what if I want to merge one particular commit of the master branch into my branch foo?
@JohnDui Then you can cherry-pick one or multiple commits from one branch to the other: stackoverflow.com/a/1994491/6309
@JohnDui but beware of issues with cherry-picking mentioned in stackoverflow.com/a/13524494/6309 (see the two links mentioned in that answer)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.