Delete commits from a branch in Git

后端 未结 30 2120
醉话见心
醉话见心 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 07:44

    Another possibility is one of my personal favorite commands:

    git rebase -i ~1
    

    This will start the rebase in interactive mode -i at the point just before the commit you want to whack. The editor will start up listing all of the commits since then. Delete the line containing the commit you want to obliterate and save the file. Rebase will do the rest of the work, deleting only that commit, and replaying all of the others back into the log.

提交回复
热议问题