How to undo the last commit in git

This question already has an answer here:

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

  • I think you haven't messed up yet. Try:

    git reset HEAD^
    

    This will bring the dir to state before you've made the commit, HEAD^ means the parent of the current commit (the one you don't want anymore), while keeping changes from it (unstaged).


    试着简单地重置最后的提交

    git reset --soft HEAD~1
    
    链接地址: http://www.djcxy.com/p/562.html

    上一篇: 如何撤消上次提交

    下一篇: 如何撤消git中的最后一个提交