博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git 回滚远程服务端master的代码
阅读量:6853 次
发布时间:2019-06-26

本文共 1717 字,大约阅读时间需要 5 分钟。

1.先备份版本

git checkout mastergit pullgit branch master_backup //备份一下这个分支当前的情况 git push origin master_backup 推送到远端服务器
 

2.切到对应的要回流的版本上

git reset --hard the_commit_id //把master本地回滚到the_commit_id

3.先删除远端的版本

git push origin :master //删除远程 master

4.推送本地的到远端服务端上面

git push origin master //用回滚后的本地分支重新建立远程分支

5.删除备份版本

git branch -d master_backup //如果前面都成功了,删除这个备份分支

流程是这样子,但是进行到第三个操作的时候就各种问题

remote: GitLab: You are not allowed to push code to protected branches on this project.To git@gitlab.ins.risk.regn.net:cmd/release.git ! [remote rejected] master -> master (pre-receive hook declined)error: failed to push some refs to 'git@gitlab.ins.risk.regn.net:cmd/release.git'

先是没有权限的错

我们用的是gitlab ,大概在   Setting中 => Protected branches 启用 master 分支可被 develop 角色提交即可。

1.那就开权限.

再次是不是

remote: error: By default, deleting the current branch is denied, because the nextremote: error: 'git clone' won't result in any file checked out, causing confusion.remote: error:remote: error: You can set 'receive.denyDeleteCurrent' configuration variable toremote: error: 'warn' or 'ignore' in the remote repository to allow deleting theremote: error: current branch, with or without a warning message.remote: error:remote: error: To squelch this message, you can set it to 'refuse'.remote: error: refusing to delete the current branch: refs/heads/masterTo /Users/along/GitHub/GitRepository/gitStudy.git ! [remote rejected] master (deletion of the current branch prohibited)error: failed to push some refs to '/Users/along/GitHub/GitRepository/gitStudy.git'

这个错,需在要远程仓库中执行,记住是远程仓库,不是本地

git config receive.denyDeleteCurrent false

参考: https://blog.csdn.net/sunalongl/article/details/52013435

https://www.centos.bz/2017/07/git-merge-and-roll-back/

感谢,解决了

 

你可能感兴趣的文章
Linux进程ID号--Linux进程的管理与调度(三)
查看>>
Xcode 编译错误
查看>>
=、==、is、id(内容)
查看>>
基于MySQL协议的数据库中间层项目Atlas - 360团队
查看>>
20165334《java程序设计》第三周学习总结
查看>>
HTTP请求GET/POST查看工具
查看>>
php实现 坐标移动
查看>>
前端之HTML
查看>>
The Cats' Feeding Spots
查看>>
Python 进阶_OOP 面向对象编程_self 的实例绑定
查看>>
jquery内核学习(5)--对象的遍历
查看>>
在Android迷你广告上添加浮动的关闭按钮
查看>>
2dcontext
查看>>
企业级大数据处理方案-01
查看>>
日期和字符串相互转换的方法
查看>>
ASP.NET Localization
查看>>
ssm框架,出现xxx不能加载,或者bean不能加载时的解决方案之一
查看>>
types.h头文件学习
查看>>
【递推】hdu5927 Auxiliary Set
查看>>
计算机的组成与操作系统
查看>>