I have multiple branches, and I would like to merge remote changes into a branch that is not my current branch.
For example:
git merge remote/branch some-other-branch
No, merging does only affect one branch.
Merging is Git's way of putting a forked history back together again. The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch. Note that all of the commands presented below merge into the current branch.
This is doable only if the local branch can be fast-forwarded to the remote head. While in any branch, to fetch the remote branch from origin and update the local head use:
git fetch origin remote_branch:local_branch
Essentially, this is the reverse of how you open a new branch at origin with git push -u origin local_branch:remote_branch
.
There's an answer to a similar question that might do what you want.
From your repo root:
git push . remote/branch:some-other-branch
This worked for me when I wanted to fast-forward master to a later commit just before I rebased to it from the branch I was in (not master).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With