Darth.Vader
Darth.Vader

Reputation: 6271

Merging changes from master into my branch

I have two branches in git: master and custom_branch.

Somebody added some code to master that I need to use in my custom_branch. I tried this:

git branch custom_branch
git merge master

But when I do that, it says:

Already up-to-date.

But, when I compare master and custom_branch, the changes are still not there. What am I missing?

P.S. I don't want to rebase since other people also use this branch.

Upvotes: 246

Views: 709918

Answers (6)

Tilman
Tilman

Reputation: 1562

git switch custom_branch # switch current working environment to custom_branch
git merge master # merge master branch into custom_branch

This will update your current branch with the changes from your local master branch, the state of which will be that of when you last pulled while on that branch.

I think this is what you are looking for: git merge origin master

Upvotes: 131

Darth.Vader
Darth.Vader

Reputation: 6271

Answering my own question but to pull changes from upstream's master into my custom branch I did this:

git pull [URL TO UPSTREAM'S REPO] master

In the end I did,

git pull origin master

Upvotes: 35

Lily
Lily

Reputation: 11

Be sure that you're on the branch you want to merge into. Command for merging master into the

git merge master && git commit -m "merging master" && git push

Upvotes: 1

Pritam Banerjee
Pritam Banerjee

Reputation: 18923

Just do:

git fetch origin master

And then do:

git merge master

Upvotes: 14

Bob van den Berg
Bob van den Berg

Reputation: 244

You probably still have to pull the changes to your local master branch. Before your commands, use git checkout master and then git pull

Upvotes: 3

tehp
tehp

Reputation: 6384

git checkout custom_branch && git rebase master

This will update custom_branch with changes from master branch.

Don't forget to make sure master is up to date first. git pull


This is also possible with git checkout custom_branch && git merge master


For an explanation on why the first one is (probably) what you should be using: When do you use git rebase instead of git merge?

Upvotes: 296

Related Questions