For a repository like this:
init---A---A2---...---[D---B---merge]---...---master
\ /
C---B2
where B
and B2
have conflict and was solved in merge commit
.
now I want to join commit A
and A2
to one commit A
. And I tried
git rebase -i <commit id of init>
and change
pick xxxxxxx A
pick xxxxxxx A2
...
to
pick xxxxxxx A
squash xxxxxxx A2
...
but conflicts appeared when applying B2, and I have to deal with the conflicts manually just like what I have done in merge
.
Actually, there are so many structures like or even more complex than in square brackets in the whole commit tree. So it's not realistic to deal with all the conflicts manually.
The problem is that when I use rebase
, the whole commit tree will merged into one line and it will not deal with the conflict automatically by applying the commit merge
.
So what can I do to join only the commits A and A2 but still remain all the commit structure after A2 unchanged so that the repository 'looks' the same after the operation?
To make some further explanation, in commit A
there's some sensitive information added in a test file and it was removed in commit A2
. So I can't publish this project if I can't remove these information permanently. So is there any alternative solution to this situation?