How to remove commits from other's in merge request
I now encounter a problem when I pull a remote branch.
Once I resolved all in case of the conflict, I have to commit all their changes.
So that once I create merge request, it includes all of them.
Thus it's hard to review. I just want to have only my commit at the moment.
How would you resolve those conflict in order to make a merge request easier to be reviewed?
I got more question as below:
Let's say I got 2 branches: A has commits (a, b)
B has commits (c, d)
. I also have created the merge requests (MR) ( MR-A
, MR-B
) to master
. So that MR-A has (a, b)
and MR-B has (c, d)
commits inside. But if I am at the A
branch then I rebase the branch B
so that MR-A has (a, b, c, d)
commits while MR-B also has (c, d)
. Finally I merge MR-A
to master
. However the MR-B still has (c, d)
And the question is: How could I remove the c, d
from MR-B
?
Rebase is what you are looking for, not merge.
Read:
When do you use git rebase instead of git merge?
What's the difference between 'git merge' and 'git rebase'?
If you pull
only (not pull --rebase
) then the resolution of a merge involves a commit (and not git add
+ git rebase --continue
)
That means you can make one or several commits to full resolve the conflict detected after a git pull.
So all you need to do is a git add -p
, to add only hunks of the conflicted files:
That way, you end up with separate commits. And you can make a more precise merge request, easier to review.
This is harder to do with a rebase, which will make only one commit once you have fixed and added to the index the files with conflicts.
How could I remove the c, d from MR-B?
You don't: you simply delete MRB: if you have rebased MRA on top of MRB, and then merge MRA to master, MRB does not have any role: all its commits have been merged.
If MRB has more commits, and you want to remove b and c, simply do a git rebase -i
: that will rebase MRB in interactive mode, allowing you to drop commits b and c, keeping other commits. Force push MRB and you can continue working on fix B.
下一篇: 如何在合并请求中删除其他人的提交