Delete commits from a branch in Git

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

    // display git commit log    
    $ git log --pretty=oneline --abbrev-commit
    
    // show last two commit and open in your default editor
    // then delete second commit line and save it
    $ git rebase -i HEAD~2
    

    Reference: How to delete a commit in git, local and remote

提交回复
热议问题