git rebase interactive: squash merge commits together

后端 未结 4 1130
灰色年华
灰色年华 2020-12-12 13:53

I wanted to have a simple solution to squash two merge commits together during an interactive rebase.

My repository looks like:

   X --- Y ---------          


        
4条回答
  •  渐次进展
    2020-12-12 14:16

    None of the mentioned methods works for me with a recent git version. In my case the following did the trick:

    git reset --soft Y
    git reset --hard $(git commit-tree $(git write-tree) -p HEAD -p stable < commit_msg)
    

    You'll have to write the commit message to the file commit_msg first, though.

提交回复
热议问题