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 ?
What you are doing is the right thing.
git checkout develop
git pull
git checkout branch1
git merge develop
I don't if you are asking for a shorthand for these commands or what, but this is the sequence I always use.
A slightly quicker option would be to (while on branch1
):
git fetch
git merge remote/develop
This will get your remote/develop
merged into branch1
, however it should be noted that your local develop branch won't be updated.
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
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