How can I reorder/combine commits using Git rebase?

后端 未结 3 784
清歌不尽
清歌不尽 2020-12-15 12:49

After quite a few hours playing with rebase, the repo still looks different from what I need:

I would like to accomplish the following tasks:
[some of which were

3条回答
  •  执笔经年
    2020-12-15 13:46

    There are a number of things you are trying to achieve here and it's a tad unclear from the diagrams provided exactly what is needed but the following pointers may help:

    • Rather than try to move your branch, I would first combine the commits you've done on that branch, then apply the final commit to the master branch since thats eventually what you are aiming at. You may have to resolve some conflicts at this point but you would have to do that anyway. See the next two tips for info on how to achieve this.

    • To combine two commits you can do aninteractive rebase.

    • To pick a single commit from one branch and apply it to another, whilst on the target branch use git cherry-pick. You can delete the old branch using git branch -D twist when done.

    Hope these tips get you on the road to your goal.

提交回复
热议问题