Git: How to squash all commits on branch

前端 未结 13 1944
情深已故
情深已故 2020-12-04 04:33

I make new branch from master with:

git checkout -b testbranch

I make 20 commits into it.

Now I want to squash those

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 05:12

    Solution for people who prefer clicking:

    1. Install sourcetree (it is free)

    2. Check how your commits look like. Most likely you have something similar to this

    3. Right click on parent commit. In our case it is master branch.

    1. You can squash commit with previous one by clicking a button. In our case we have to click 2 times. You can also change commit message

    2. Results are awesome and we are ready to push!

    Side note: If you were pushing your partial commits to remote you have to use force push after squash

提交回复
热议问题