How to rebase after squashing commits in the original branch?

前端 未结 2 1826
名媛妹妹
名媛妹妹 2020-12-29 06:42

I have

A--B--C master
       \\
        D branch0

Then I squash B and C into B\'. How do I rebase

2条回答
  •  梦谈多话
    2020-12-29 07:33

    One quick way I can think of is,

    git checkout branch0

    Note down the sha of the D commit by git log

    git checkout master

    Now rename the branch0 to branch1

    git branch -m branch0 branch1

    A--B' master \ D branch1

    Now delete branch1

    git branch -D branch1

    Create a branch0 again as follows. git checkout -b branch0

    A--B' - master&branch0 After the above command master and branch0 are same. Only change we need to make in branch0 is get the commit D.

    git cherry-pick D

    Now branch0 looks as follows

    A--B' master \ D branch0

提交回复
热议问题