Larry Martell
Larry Martell

Reputation: 3756

git: how to merge directly from github without first merging to local branch

When I want to merge to a local branch I do this:

git checkout master
git pull origin master
git checkout my_branch
git merge master

Is there a way to merge from the master on the repository into my local my_branch without first pulling into my local master?

I tried git merge origin/master but that did not pick up commits that were on the repository but not in the local master.

Upvotes: 0

Views: 80

Answers (2)

Schleis
Schleis

Reputation: 43750

You need to update the state of the remote branch before you do your git merge.

The following should work for you (assuming you are on my_branch):

git fetch
git merge origin/master

This will update with the information from the remote with the commits that are not yet in your local master. Then you can merge the remote branch into my_branch.

Upvotes: 3

jlreymendez
jlreymendez

Reputation: 107

You can do this:

git checkout my_branch    
git pull origin master

Update: I didn't understand you needed also local changes. For that you can also merge them with.

git merge master 

Upvotes: 3

Related Questions