How do I delete unpushed git commits?

前端 未结 7 1164
轮回少年
轮回少年 2020-11-28 16:45

I accidentally committed to the wrong branch. How do I delete that commit?

7条回答
  •  日久生厌
    2020-11-28 17:35

    Delete the most recent commit, keeping the work you've done:

    git reset --soft HEAD~1
    

    Delete the most recent commit, destroying the work you've done:

    git reset --hard HEAD~1
    

提交回复
热议问题