git pull 错误:[remote rejected] master -> master (pre-receive hook declined)

错误场景

本次错误的场景是关于在 gitlab 上删除历史提交中的大文件最后执行 git push 触发的

$ git push
Enter passphrase for key '/c/Users/edz/.ssh/id_rsa':
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (18/18), 1.74 KiB | 893.00 KiB/s, done.
Total 18 (delta 3), reused 18 (delta 3)
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
 ! [remote rejected] master -> master (pre-receive hook declined)
 ! [remote rejected] release-1.0 -> release-1.0 (pre-receive hook declined)
 ! [remote rejected] release-2.0 -> release-2.0 (pre-receive hook declined)
 ! [remote rejected] v1.4 -> v1.4 (pre-receive hook declined)
 ! [remote rejected] v1.5 -> v1.5 (pre-receive hook declined)
error: failed to push some refs to ''
step1:
  • 首先需要确认的是你已经具有了仓库的 master 权限吗?如果已经具有了跳过此步。

如果没有肯定是不行的,所有需要先具有分支的 master 操作权限,这一点不适合我,因为就是我创建的仓库,所以我肯定是 master 权限。

git pull 错误:[remote rejected] master -> master (pre-receive hook declined)_第1张图片

step2:
  • 关闭分支的保护机制

我推断可能是因为删除了大文件而触发的问题。找到仓库的设置,点击取消保护 unprotected

在这里插入图片描述

git pull 错误:[remote rejected] master -> master (pre-receive hook declined)_第2张图片
因为我这里已经删除了,没有删除的在右下角可以取消保护。最后成功。

$ git push
Enter passphrase for key '/c/Users/edz/.ssh/id_rsa':
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (18/18), 1.74 KiB | 893.00 KiB/s, done.
Total 18 (delta 3), reused 18 (delta 3)
remote:
remote: To create a merge request for release-1.0, visit:
rmerge_request%5Bsource_branch%5D=release-1.0
remote:
remote: To create a merge request for release-2.0, visit:
merge_request%5Bsource_branch%5D=release-2.0
remote:
 + f590fbc...317cedb master -> master (forced update)
 + f590fbc...317cedb release-1.0 -> release-1.0 (forced update)
 + f590fbc...317cedb release-2.0 -> release-2.0 (forced update)
 + 4d2ac96...0ecb3ff v1.4 -> v1.4 (forced update)
 + 5b3f186...d967bac v1.5 -> v1.5 (forced update)

你可能感兴趣的:(git,使用,git,push,git,push,protected,unprotected)