命令行输入
git log
打开git版本记录页,找到需要恢复的历史版本,复制后输入
:q
退出log文本。
或者可以在idea上右键--git--show history找到需要恢复的历史版本在其上右键--copy revision number以复制版本号。
然后恢复当前代码到指定版本:
git reset --hard 24a28a363bb46252540aeeb7ce50c2bf6715447d
强推代码:
git push -f origin master
可能会得到一个错误
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
那是因为菩萨保佑的,我们打开git管理界面找到这个项目,依次点击settings--repository,滚动界面找到如下:
不迷信,直接点unprotect,高兴的话回头再拜
这回再去强推就不会报错了