How to revert multiple git commits?

后端 未结 13 2375
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 07:36

I have a git repository that looks like this:

A <- B <- C <- D <- HEAD

I want the head of the branch to point to A, i.e. I want B

13条回答
  •  盖世英雄少女心
    2020-11-22 08:07

    I'm so frustrated that this question can't just be answered. Every other question is in relation to how to revert correctly and preserve history. This question says "I want the head of the branch to point to A, i.e. I want B, C, D, and HEAD to disappear and I want head to be synonymous with A."

    git checkout 
    git reset --hard 
    git push -f
    

    I learned a lot reading Jakub's post, but some guy in the company (with access to push to our "testing" branch without Pull-Request) pushed like 5 bad commits trying to fix and fix and fix a mistake he made 5 commits ago. Not only that, but one or two Pull Requests were accepted, which were now bad. So forget it, I found the last good commit (abc1234) and just ran the basic script:

    git checkout testing
    git reset --hard abc1234
    git push -f
    

    I told the other 5 guys working in this repo that they better make note of their changes for the last few hours and Wipe/Re-Branch from the latest testing. End of the story.

提交回复
热议问题