! [remote rejected] master -> master (pre-receive hook declined) – Git Error

Total
0
Shares

! [remote rejected] master -> master (pre-receive hook declined) is the error we receive when either the branch is marked protected or you don’t have permission to push.

According to GitHub Docs

pre-receive hooks are the scripts that run on the GitHub Enterprise server that you can use to implement quality checks.

Generally, you will get this error in GitLab because it marks the master branch as protected by default.

Since a number of collaborators work on a single branch, it is necessary for version management systems to keep the projects free from anomalies. GitLab has a safety layer for it.

To remove the protection, follow these steps –

  • Go to project Settings.
  • Click on Repository tab.
  • Open Protected Branches.
  • Find your master branch and click on Unprotect.

Overall, check for these issues –

  1. Is your login credentials (SSH Keys) are correct and connected to your git project?
  2. Do you have permission to push your commit? Check if you are developer or maintainer.
  3. Is the configuration correct?
  4. Check if project is unprotected.
  5. You need to pull the changes first before pushing your commit.

    Tweet this to help others