Gitlab回滚到上次提交
1、查看所有commits記錄
$?git log
2、 gitlab回退到某次commit
$ git reset --hard 3018a546427e1f865524b82b488d6a2721d00759
$ git reset 3018a546427e1f865524b82b488d6a2721d00759
注意:3018a546427e1f865524b82b488d6a2721d00759為commit id
3、強(qiáng)制重新提交到遠(yuǎn)程
$ git push -f
git報(bào)錯(cuò)You are not allowed to force push code to a protected branch on this project解決方案
當(dāng)我們有時(shí)候回滾了代碼,想強(qiáng)制push到遠(yuǎn)程倉(cāng)庫(kù)的時(shí)候,
$ git push origin --force
會(huì)報(bào)如下錯(cuò)誤:
You are not allowed to force push code to a protected branch on this project
如果用的是gitlab版本庫(kù),這說明gitlab對(duì)倉(cāng)庫(kù)啟用了保護(hù),需要在倉(cāng)庫(kù)中設(shè)置一下:
"Settings" -> "Repository" -> scroll down to "Protected branches". -> 找到項(xiàng)目,點(diǎn)擊"Unprotect"按鈕,使項(xiàng)目不受保護(hù)。
重新執(zhí)行如下命令即可:
$ git push origin --force
總結(jié)
以上是生活随笔為你收集整理的Gitlab回滚到上次提交的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Voronoi Noise
- 下一篇: WRF运行问题