I have a feature branch that I want to merge with master. Before I do that, I would like to squash a few commits.
I already did a merge from master onto this feature branch to resolve the conflicts. The commits I want to squash are before the merge commit from master.
The merge contains 180 commits coming from master, and it was a big struggle to handle conflicts so I want to avoid redoing it while rebasing.
The git log is this:
A
|
B (merge commit)
|
C (22 commits from master)
|
X
|
Y
|
Z
|
D (coming from master)
|
E (coming from master)
|
F (coming from master)
|
...
... (more 155 commits from master)
...
I want to squash X
and Y
onto Z
. When I do
git rebase -i HEAD~6
It is showing all the commits from master coming with the merge commit, so when I want to squash only X
and Y
, I need to resolve the conflicts once again.
How can I prevent that?
Try adding the -r | --rebase-merges
-r | --rebase-merges
to your rebase command:
git rebase -i -r HEAD~6
The sequencer script will look different, you will quickly figure out that it describes a way to describe how you want to replay your merges.
In your case: you just want to squash X
, Y
and Z
together, you shouldn't have to edit the merge part.
The default behavior of git rebase
(without -r
) is to:
this is why your conflicts are triggered again
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.