! [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 –
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
masterbranch and click on Unprotect.
Overall, check for these issues –
- Is your login credentials (SSH Keys) are correct and connected to your git project?
- Do you have permission to push your commit? Check if you are developer or maintainer.
- Is the configuration correct?
- Check if project is unprotected.
- You need to pull the changes first before pushing your commit.