git 撤销修改:未push 、已push |
您所在的位置:网站首页 › git撤销push到未提交状态 › git 撤销修改:未push 、已push |
场景:不小心把一次错误的代码push到远程服务器上的分支上,需要立即删除/撤销这次代码提交。 具体方法,git命令: git loggit reset --hard git 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) |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |