Reputation: 8582
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 ?
Upvotes: 25
Views: 64241
Reputation: 2398
What you are doing is the right thing.
git checkout develop
git pull
git checkout branch1
git merge develop
This will merge the
develop
branch intobranch1
I don't know if you are asking for a shorthand for these commands or what, but this is the sequence I always use.
Alternatively, from your current branch branch1
do
git pull origin develop
git push
This will merge develop
branch into your branch1
and push to update upstream branch1
Upvotes: 36
Reputation: 27818
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
Upvotes: 4
Reputation: 9866
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.
Upvotes: 19