git 回退到指定版本

yuyu888 于 2022-02-24 发布

1、查看提交的历史记录,获取到某个历史版本的id

 git log

2、本地分支回滚到指定版本

git reset --hard 9e829ecb3e939572b454d2dfe02125cf29eac5aa

3、强制推送到远程分支

git push -f origin your_branch

如果出现一下错误

remote: GitLab: You are not allowed to force push code to a protected branch on this project.

图例

可以通过一下设置打开
图例