Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

How to fix the GitLab pre-receive hook declined error

This article will discuss ways of fixing the GitLab error: GitLab pre-receive hook declined.

While working on a new Gitlab repository, one of our developers received the GitLab push error:

! [remote rejected]   main -> main (pre-receive hook declined)

This issue can be because of one of two reasons.

What is the GitLab pre-receive hook declined error?

The whole repository or a file inside the repository exceeds the size limit. You can verify this by reading the error message in detail, it should mention this clearly:

GitLab: You are attempting to check in one or more blobs which exceed the 100.0MiB limit:

The second reason is that the branch is protected and/or the dev does not have sufficient permissions.

How to fix the GitLab pre-receive hook declined error

Navigate to Gitlab > Repo > Settings > Repository and scroll down to Protected Branches

You a few options here.

  1. Remove the protected branch altogether. Note: this is dangerous
  2. Elevate the dev’s privileges to the required group.
  3. Change who the group under Allowed to merge and Allowed to push and merge.

That’s it!

Further Resources

Gitlab: Git Server Hooks

GitLab: Push Rules

Pre-receive hook declined Windows 11

Git error when trying to push — pre-receive hook declined