Undo several commits in git which have not pushed to remote

This question already has an answer here:

  • How to undo the most recent commits in Git? 69 answers

  • 这将丢弃工作树中的所有本地更改以及四个最新的提交:

    git reset --hard HEAD~4
    

    You can also run the following to reset to the remote's HEAD:

    git reset --hard <REMOTE>/<BRANCH_NAME>
    

    Ex:

    git reset --hard origin/master
    
    链接地址: http://www.djcxy.com/p/570.html

    上一篇: 意外地在git中犯下

    下一篇: 在git中还没有推送到远程的几个提交