Revert a merge after being pushed

前端 未结 4 1698
灰色年华
灰色年华 2021-01-30 05:19

Steps i performed:

I have two branches branch1 and branch2,

$git branch --Initial state
$branch1

$git checkout branch2
$git pull origin branch1 --Step1
         


        
4条回答
  •  终归单人心
    2021-01-30 05:23

    The first option is the use of git revert.

    git revert -m 1 [sha-commit-before-merge]
    

    The git revert will revert the changes but will keep the history. Therefore you will not be able to continue working in the same branch since you cannot see the actual difference between the merged branch and your feature branch anymore. Use the following way to remove history as well. Do this very carefully if and only if you are the only one pushing changes to the branch at the moment.

    git reset --hard [sha-commit-before-merge]
    git push [origin] [branch] --force
    

提交回复
热议问题