解决 Gitlab force push 权限问题

解决 Gitlab: You are not allowed to force push code to a protected branch on this project 问题

大家好,今天碰到了个小问题,记录下解决方法

当我们有强制push到远程仓库需求的时候,会使用--force

1
2
# 例如我的blog
git push [email protected]:augustdoit/blog.git master --force

会报如下错误

1
2
3
Gitlab: You are not allowed to force push code to a protected branch on this project
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:augustdoit/blog.git'

这说明==Gitlab==对仓库启用了保护,需要在仓库设置一下

进入到仓库-设置-仓库-受保护分支-勾选允许强制推送