Delete commits from a branch in Git

后端 未结 30 2593
醉话见心
醉话见心 2020-11-21 07:17

I would like to know how to delete a commit.

By delete, I mean it is as if I didn\'t make that commit, and when I do a push in the future, my changes wi

30条回答
  •  深忆病人
    2020-11-21 08:02

    I'm appending this answer because I don't see why anyone who has just tried to commit work would want to delete all that work because of some mistake using Git!

    If you want to keep your work and just 'undo' that commit command (you caught before pushing to repo):

    git reset --soft HEAD~1
    

    Do not use the --hard flag unless you want to destroy your work in progress since the last commit.

提交回复
热议问题