Undoing a 'git push'

前端 未结 12 1099
遥遥无期
遥遥无期 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:17

    The existing answers are good and correct, however what if you need to undo the push but:

    1. You want to keep the commits locally or you want to keep uncommitted changes
    2. You don't know how many commits you just pushed

    Use this command to revert the change to the ref:

    git push -f origin refs/remotes/origin/@{1}:
    

提交回复
热议问题