Git:从pull请求中删除所有提交

时间:2017-01-31 10:55:22

标签: git

我有一个Pull Request,我已经添加了提交。但是,我想从该PR中删除所有提交并从头开始。我在哪里可以再次添加我的提交?

我使用git rebase,但我对如何使用它并不太了解。

请指导我。

1 个答案:

答案 0 :(得分:1)

如果您要删除N次提交,则可以使用--hard reset HEAD~N

$ git branch -b backup               # backup the branch for safety

$ git log                            # count how many commits you want to remove

$ git reset --hard HEAD~3            # Let, you want to remove 3 commits here   
$ git push -f origin HEAD            # force (-f) push to remote as you rewrite the history
相关问题