Delete commits from a branch in Git

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

    If you didn't publish changes, to remove latest commit, you can do

    $ git reset --hard HEAD^
    

    (note that this would also remove all uncommitted changes; use with care).

    If you already published to-be-deleted commit, use git revert

    $ git revert HEAD
    

提交回复
热议问题