rebase to squash multiple commits on same branch

前端 未结 2 1487
执念已碎
执念已碎 2021-02-14 04:55

Can we use rebase to squash multiple commits into one single commit on the same branch?

Taking an example, i have created two topic branches - issueA_1 and issueA_2 from

相关标签:
2条回答
  • 2021-02-14 05:35

    In your case,

    git checkout issueA_2
    git rebase -i master
    

    or

    git rebase -i commitX1^ #parent of commitX1 in branch issueA_2
    

    should also work. In this case, you don't need to count (I'm usually one off).

    0 讨论(0)
  • 2021-02-14 05:43

    Yes, the simplest way I find is to do:

    git rebase -i HEAD~3
    

    This will let you review the last 3 commits and you can then squash them.

    0 讨论(0)
提交回复
热议问题