Remove a git commit which has not been pushed

前端 未结 11 736
抹茶落季
抹茶落季 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条回答
  •  旧时难觅i
    2020-12-04 05:02

    IF you have NOT pushed your changes to remote

    git reset HEAD~1
    

    Check if the working copy is clean by git status.

    ELSE you have pushed your changes to remote

    git revert HEAD
    

    This command will revert/remove the last one commit/change and then you can push

提交回复
热议问题