Squash my last X commits together using Git

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

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

30条回答
  •  执念已碎
    2020-11-21 05:53

    I think the easiest way to do this is by making a new branch based on master and doing a merge --squash of the feature branch.

    git checkout master
    git checkout -b feature_branch_squashed
    git merge --squash feature_branch
    

    Then you have all of the changes ready to commit.

提交回复
热议问题