git master分支还原到指定版本

1.查看日志,复制想还原到的commit号A

假设A=30c8404a0c9a58452c23f509e7ee19eace06c50d

git log

2.还原代码到版本A

git reset --hard 30c8404a0c9a58452c23f509e7ee19eace06c50d

3.强制更新到远端分支

git push -f origin master

4.如果3有报错
在这里插入图片描述
去gitlab检查项目master分支是否被保护

Setting>Registry>Protected Branches UnProtect master分支后

重试执行步骤3

git push -f origin master

记得还原受保护的分支

Setting>Registry>Protected Branches Protect master分支后

猜你喜欢

转载自blog.csdn.net/jianleking/article/details/104300860