场景:不小心把一次错误的代码push到远程服务器上的分支上,需要立即删除/撤销这次代码提交。
具体方法,git命令:
git reset --hard <commit_id>
git push origin HEAD --force
commit_id可以通过git命令:
git log
输出获取。
commit_id形如:126f206185f225879f2723ca421f4dee44ca8fe7
然后完整命令:
git reset --hard 126f206185f225879f2723ca421f4dee44ca8fe7
git push origin HEAD:develop --force
参考地址:http://m.yiibai.com/git/git_push.html