Reputation: 341
I'm in this scenario:
feature
)graphics
), where I worked too (keeping in standby the other branch)feature
The branch graphics
will be merged into master after finished and reviewed, but now I want to integrate the graphics
changes also into my branch feature
that also will be merged with master after finished.
So we'll have to merge the feature
into master, after graphics
had been already merged.
What is the best way to do this? Could I rebase feature
with graphics
changes? Or merge graphics
into feature
(in this way will I have the merge graphics
twice? )? Or must I cherry-pick all commits?
I hope is clear my scenario!
Upvotes: 2
Views: 3199
Reputation: 1643
Scenario 1,
When the graphics
is merged into the master
;
In this case you can rebase your feature
branch from the master
as the graphics
branch changes are there in master
.
Scenario 2,
When the graphics
branch isn't merged yet and you need the changes;
In this case there are two possibility,
i. Merge the graphics
branch into your feature
branch by just taking the graphics
branch pull in the feature
branch, say you in feature branch then git pull origin graphics
.
ii. Do rebase
your feature
branch against the graphics
branch, say you are feature branch the do git rebase feature
and git rebase --continue
unless all rebase conflicts and merge conflicts resolved.
The best is to rebase your branch with the graphics
branch and then let the graphics
branch be merged to master
and then create a pull request agains the master. This would be great to do.
Upvotes: 0
Reputation: 8345
First, merge graphics
into master
. Then, rebase feature
on top of master
.
git checkout master
git merge graphics
git checkout feature
git rebase master
This way, you will acquire the graphics
changes and still keep an uncluttered history in feature
.
It is highly inadvisable to merge graphics
into feature
before merging it into master
unless you have a particular reason for that.
But if you do have a particular reason, then just go ahead and do it...
git checkout feature
git merge graphics
Note that depending on circumstances you may want to do a git rebase graphics
instead of git merge graphics
. The end result (the content of your files on feature
) will be exactly the same, but the history a.k.a. the commit tree will look different. The latter will avoid any kind of extra conflicts when you finally merge both branches into master
and will look very clean; I would likely prefer that. But hard to tell without knowing what you want to achieve.
N.B. if you do a git rebase
, and later commit more onto graphics
, then you need to do the git rebase
again before the final merge into master
(I suggest doing that immediately after you merged graphics
into master
).
Upvotes: 2