Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

People also ask

What is pre-receive Hook declined in git?

Your commits were rejected by the pre-receive hook of that repo (that's a user-configurable script that is intended to analyze incoming commits and decide if they are good enough to be accepted into the repo). It is also a good idea to ask that person to update the hook, so it would print the reasons for the rejection.

What is pre-receive hook github?

Pre-receive hooks enforce rules for contributions before commits may be pushed to a repository. Pre-receive hooks run tests on code pushed to a repository to ensure contributions meet repository or organization policy. If the commit contents pass the tests, the push will be accepted into the repository.

How do I force git push?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).


You should ask whoever maintains the repo at git@mycogit/cit_pplus.git.

Your commits were rejected by the pre-receive hook of that repo (that's a user-configurable script that is intended to analyze incoming commits and decide if they are good enough to be accepted into the repo).

It is also a good idea to ask that person to update the hook, so it would print the reasons for the rejection.

If the maintainer is you yourself, then it looks like you've got a problem with your setup on the server-side. Please share more information then.


I'd bet that you are trying a non-fast-forward push and the hook blocks it. If that's the case, simply run git pull --rebase before pushing to rebase your local changes on the newest codebase.


File size is important. There is a limit of ~120MB for a single file. In my case, .gitignore using Visual Studio had the file listed, but the file was still committed. When using the git cli, we can get more detail information about the error.

pre-receive hook declined was as a result of the big file. Basically validating the push.

To resolve it, I removed the last commit using:

git reset --soft HEAD~1

I then excluded the file from the commit.

Note: Use HEAD~N to go back to N number of previous commits. (i.e. 3, 4) Always use the --soft switch to maintain changes in the folder

hope it helps.


In my case I got this message because the branch was marked as 'Protected' in GitLab.