Squash my last X commits together using Git

前端 未结 30 3461
醉酒成梦
醉酒成梦 2020-11-21 05:17

How can I squash my last X commits together into one commit using Git?

30条回答
  •  遇见更好的自我
    2020-11-21 05:50

    2020 Simple solution without rebase :

    git reset --soft HEAD~2

    git commit -m "new commit message"

    git push -f

    2 means the last two commits will be squashed. You can replace it by any number

提交回复
热议问题