git回滚到任意版本
一、先显示提交的log (-3为显示最近的3条记录)
$ git log -3
commit 4dc08bb8996a6ee02f
Author: Mark <[email protected]>
Date: Wed Sep 7 08:08:53 2016 +0800
xxxxx
commit 9cac9ba76574da2167
Author: xxx<[email protected]>
Date: Tue Sep 6 22:18:59 2016 +0800
improved the requst
commit e377f60e28c8b84158
Author: xxx<[email protected]>
Date: Tue Sep 6 14:42:44 2016 +0800
changed the password from empty to max123
二、回滚到指定的版本(soft、hard、mixed参数的区别在文章最后)
git reset --hard e377f60e28c8b84158
三、强制提交(-f 表示force 强制提交)
git push -f origin master
通常这一步提交会报错,因为分支是受保护的,不允许强制覆盖提交,这时候登录gitLab,找到要强制提交的项目,点击页面最右边的设置,找到protected branches