Delete commits from a branch in Git

后端 未结 30 2066
醉话见心
醉话见心 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条回答
  •  -上瘾入骨i
    2020-11-21 08:00

    If you've already pushed, first find the commit you want to be at HEAD ($GIT_COMMIT_HASH_HERE), then run the following:

    git reset --hard $GIT_COMMIT_HASH_HERE
    git push origin HEAD --force
    

    Then each place the repo has been cloned, run:

    git reset --hard origin/master
    

提交回复
热议问题