0

I have a branch with consecutive merges from another branch; there are no non-merge-commits in between, like:

  E-----G-----J
 /     /     /
A-B-C-D-F-H-I

where G and J are the consecutive merge commits.

How can i squash G and J into J to get the following picture?

  E-----------J
 /           /
A-B-C-D-F-H-I

I tried with interactive rebase but that led to editing some merge conflicts again which shouldn't have overlapped between the two merges G and J.

I also tried a shortcut but with that all merge information is lost. Maybe "fixing" that afterwards with a fake merge could work but i didn't succeed.

ridilculous
  • 307
  • 8
  • 1
    `git commit-tree -p E -p I -m "Merge message" J^{tree}` – Raymond Chen Jan 31 '22 at 21:50
  • @RaymondChen Whoa! Such easy if you know how :D Exactly what i've been looking for! – ridilculous Jan 31 '22 at 23:05
  • Looks like there's a fuller explanation here: [How to "squash" subsequent merge commits](https://stackoverflow.com/a/58803756) – Raymond Chen Feb 01 '22 at 01:51
  • @RaymondChen Your comment led me straight to the solution; i only had to figure out what to do with the resulting hash which i found out [here](https://stackoverflow.com/questions/29623837/what-is-the-difference-between-git-commit-and-git-commit-tree) where the helpful [Git from the bottom up](https://jwiegley.github.io/git-from-the-bottom-up/1-Repository/4-how-trees-are-made.html) has been [mentioned](https://stackoverflow.com/questions/29623837/what-is-the-difference-between-git-commit-and-git-commit-tree#comment72954537_29623935). – ridilculous Feb 01 '22 at 08:48

0 Answers0