Remove a git commit which has not been pushed

前端 未结 11 725
抹茶落季
抹茶落季 2020-12-04 04:34

I did a git commit but I have not pushed it to the repository yet. So when I do git status, I get \'# Your branch is ahead of \'master\' by 1 commi

11条回答
  •  既然无缘
    2020-12-04 05:10

    This is what I do:

    First checkout your branch (for my case master branch):

    git checkout master
    

    Then reset to remote HEAD^ (it'll remove all your local changes), force clean and pull:

    git reset HEAD^ --hard && git clean -df && git pull
    

提交回复
热议问题