How do I delete unpushed git commits?

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

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

7条回答
  •  时光取名叫无心
    2020-11-28 17:22

    If you want to move that commit to another branch, get the SHA of the commit in question

    git rev-parse HEAD
    

    Then switch the current branch

    git checkout other-branch
    

    And cherry-pick the commit to other-branch

    git cherry-pick 
    

提交回复
热议问题