Merge a remote branch into another local branch

To merge remoteBranch into localBranch

git fetch
git merge localBranch remoteName/remoteBranch

where remoteName is probably "origin", you can find that by git remote -v

However, sometimes you may want to rebase (re-writing history to keep sequence of commits "clean") instead of merge (which also adds a merge commit)

Merge vs. Rebase

You can rebase a remoteBranch into a localBranch using:

git fetch
git checkout localBranch
git rebase remoteName/remoteBranch

ref: https://www.atlassian.com/git/tutorials/merging-vs-rebasing


According to the documentation of git-merge you can merge any other branch with your local branch.

Your current branch has to be your localBranch. To merge the remote branch simply type:

git merge remoteName/remoteBranch

In this case I assumed the name of your remote that contains the branch you need to be called remoteName. It may be called differently like origin or upstream. You need to make sure that your local reference to the remove branch is up to date. So perform a fetch command before doing the merge like so:

git fetch remoteName

Does this help you?


Simply merge it.

git fetch
git checkout localBranch
git merge remoteBranch

Tags:

Git

Github