Git merge other branch into another branch?

Viewed 29363

Is it possible to merge other branch into another branch?

For example, I'm in branch1 and want to pull remote/develop into develop branch and then merge develop into current branch1.

What am I doing is checkout develop(maybe stash first), pull, checkout branch1 and then merge develop.

Is it possible to do all these with switch to develop branch ?

3 Answers

A simple option would be to (while on branch1):

git fetch origin develop:develop
git merge develop

This will fetch develop from the remote origin and point your local develop branch to it, and then get your (now updated) local develop branch merged into branch1.

In case your local develop has diverged from the remote and you want to replace it with what's in the remote, then use --force to tell Git to override your local develop

git fetch origin develop:develop --force
git merge develop
Related