深圳一建公司地址,安徽网络seo,食品网站源码,商城软件开发多少钱场景#xff1a;不小心把一次错误的代码push到远程服务器上的分支上#xff0c;需要立即删除/撤销这次代码提交。
具体方法#xff0c;git命令#xff1a;
git loggit reset --hard commit_idgit push origin HEAD --force【命令详解】
获取commit_id#xff1…场景不小心把一次错误的代码push到远程服务器上的分支上需要立即删除/撤销这次代码提交。
具体方法git命令
git loggit reset --hard commit_idgit push origin HEAD --force【命令详解】
获取commit_id git log commit_id形如126f206185f225879f2723ca421f4dee44ca8fe7
版本回退
git reset --hard 126f206185f225879f2723ca421f4dee44ca8fe7 如果想回退的内容未git push不需要执行以下步骤
推到线上
已经git push需要重新push覆盖线上代码如果回退的内容 git push --force
执行git push --force 强制回退可能会遇到gitlab设置了master分支保护机制 Master分支被保护报错GitLab: You are not allowed to force push code to a protected branch on this project.
Master分支被保护
进入项目gitlab 网页版: 设置setting-版本库repo -- 保护分支把保护的分支选择 unprotected