Undoing a 'git push'

前端 未结 12 1102
遥遥无期
遥遥无期 2020-11-22 13:45

Here\'s what I did on my supposed-to-be-stable branch...

% git rebase master
First, rewinding head to repla         


        
12条回答
  •  执念已碎
    2020-11-22 14:21

    If you want to ignore the last commit that you have just pushed in the remote branch: this will not remove the commit but just ignoring it by moving the git pointer to the commit one earlier, refered by HEAD^ or HEAD^1

    git push origin +HEAD^:branch
    

    But if you have already pushed this commit, and others have pulled the branch. In this case, rewriting your branch's history is undesirable and you should instead revert this commit:

    git revert 
    git push origin branch
    

提交回复
热议问题