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.

可以通过一下设置打开

其他
删除大量文件后,想要恢复部分文件
git checkout origin/<分支名> -- <文件地址>文件地址>分支名>
例如:
git checkout origin/payroll-for-ps-yr20250919 -- microservice-payroll/src/main/java/com/xxxx/infocenter/attendanceservice/manage/logic/impl/SpecialDayLogicImpl.java