e2

滴滴侠,fai抖

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

案例: 将dev分支的代码完全覆盖到master上。

  1.  
    git checkout master
  2.  
    git reset --hard dev
  3.  
    git push origin master --force

若被覆盖的分支有处于受保护(protected)的状态,则执行push操作后会报错:

  1.  
    remote: GitLab: You are not allowed to force push code to a protected branch on this project.
  2.  
    To https://git.xxx.cn/xxx/xxx.git
  3.  
    ! [remote rejected] master -> master (pre-receive hook declined)

这时我们只需要登录到git的网页端,首先进入待覆盖的分支,接着找到Protected Branch菜单项,将待覆盖的分支从受保护的分支中移除,最后重新执行上述语句即可。

posted on 2022-09-26 14:14  纯黑Se丶  阅读(1069)  评论(0编辑  收藏  举报