Delete commits from a branch in Git

后端 未结 30 2053
醉话见心
醉话见心 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:52

    All the commands above restore the state of your work tree and index as they were before making the commit, but do not restore the state of the repository. If you look at it, the "removed" commit is not actually removed, it is simply not the one on the tip of the current branch.

    I think that there are no means to remove a commit with porcelain commands. The only way is to remove it from the log and reflog and then to execute a git prune --expire -now.

提交回复
热议问题