How can I make a complex octopus merge?

前端 未结 2 1420
一向
一向 2021-02-09 22:11

I just make 8 different suggestions off of the tip of master, and I want to make a commit that merges all of them together. I\'ve done the merges by manually resolving merge con

2条回答
  •  -上瘾入骨i
    2021-02-09 22:25

    If you'd prefer not to use plumbing directly (and who could blame you?) then you may be able to rebase your problems away.

    The trick here is that you have one commit with your actual changes in it, and a single parent, and another with no changes but multiple parents. If you squash changes together, then the first commit's parents remain.

    At the moment, your commits are in the wrong order to do a squash: the second commit, with its parents, would be lost. But because that commit has no changes, it should be possible to re-order them so the squash will work.

    If you're working on master, and origin/master points at the last commit before you started, then do git rebase -i origin/master which should give you two commits in an editor:

    pick 12345 All changes here
    pick 67890 Octopus merge
    

    Move the second line up, then squash in the changes:

    pick 67890 Octopus merge
    squash 12345 All changes here
    

    Save and exit, and I hope that works :).

提交回复
热议问题