How can I undo a `git commit` locally and on a remote after `git push`

后端 未结 7 1140
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 03:28

I have performed git commit followed by a git push. How can I revert that change on both local and remote repositories?

$ git log
         


        
7条回答
  •  既然无缘
    2020-12-02 04:07

    git reset --hard HEAD~1
    git push -f  
    

    (Example push: git push -f origin bugfix/bug123)

    This will undo the last commit and push the updated history to the remote. You need to pass the -f because you're replacing upstream history in the remote.

提交回复
热议问题