Squash my last X commits together using Git

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

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

30条回答
  •  轮回少年
    2020-11-21 05:47

    To squash the last 10 commits into 1 single commit:

    git reset --soft HEAD~10 && git commit -m "squashed commit"
    

    If you also want to update the remote branch with the squashed commit:

    git push -f
    

提交回复
热议问题