Split branch into one branch per commit

北慕城南 提交于 2019-12-02 06:09:35

In this answer, I will assume that your branch is called feature, and that feature has the three commits in question as its three most recent commits.

Create a new branch from feature:

git checkout -b onecommit

Nuke the two most recent commits, leaving the first of three commits remaining:

git reset --hard HEAD~2

Now push this branch containing just the first commit to your repo:

git push origin onecommit

To obtain a branch with just two commits you would follow a similar process:

git checkout -b twocommits
git reset --hard HEAD~1
git push origin twocommits
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!