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

When I try and push a change I’ve commited, I get the following error …

git.exe push -v --progress  "origin" iteration1:iteration1

remote: *********************************************************************
To ssh://[email protected]/cit_pplus.git
! [remote rejected] iteration1 -> iteration1 (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]/cit_pplus.git'

What’s going on?

28 Answers

You should ask whoever maintains the repo at [email protected]/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.

This may be because you didn’t have the access right to push a commit to a branch such as master. You can ask the maintainer to give you the right to push commits.

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

I got this message when the GitLab server was undergoing some changes. The next day pushing worked fine. Anyways, as others pointed out, check with your maintainer to be sure.

I had this issue when trying to merge changes with file size greater than what remote repository allowed (in my case it was GitHub)

I encountered this same issue.
What solved it for me was to switch to another branch and then back to the original one.

Not sure what the underline cause was, but this fixed it.

Bitbucket: Check for Branch permissions in Settings (it may be on ‘Deny all’). If that doesn’t work, simply clone your branch to a new local branch, push the changes to the remote (a new remote branch will be created), and create a PR.

In case it helps someone :

I had a blank repo with no master branch to unprotect (in Gitlab) so before running git push -u origin --all

  • I had to run git push -u origin master first,
  • unprotect the master branch temporarily
  • push the rest (--all & --tags)

I faced the same error, upon checking I had a developer access and couldn’t publish a new branch. Adding higher access rights resolved this issue.(Gitlab)

I got this error with GitHub gist. I was trying to push a commit with files in sub-directories. Turned out gist can only have files in root directory.

Remove the protected branch option or allow additional roles like developers or admins to allow these users experiencing this error to do merges and push.

in sometimes, because the branch you are pushing has been protected, so you can ask the repository’s maintainers to change the protecting status. in git-lab , you can find it in

Settings > Repository > Protected Branches .


In my case, we have hooks for commit messages, our server script accepts commits if they have the special format for commit message"<JIRA ID><Message>". It(hook) declines commit if respective Jira ticket does not exist or there are some special symbols in the commit message. I face this error when I add /, [, > etc. in a commit message, removing those works fine.

This is actually happens when YACC is enabled at server side in BitBucket. YACC is enable for JIRA issue names to be mentioned in the commit message. So whenever you commit anything atleast keep your JIRA number into the commit message and then additionally you can add your own message.

I was using GitKraken and we made a local branch, then we merged two remote branches in it and then we tried to push the local branch to origin. It didn’t work with the same error message.

The solution was to create the local branch and push it first to origin and then do the merge.

Issue: “PUSH Failed refs/head/ – pre-receive hook declined”

I’ve faced the problem of unable to push my changes to my origin branch and anything to master branch of a particular project repository as the size of that repo was over hard limit of 2GB. It was throwing the error. That’s because we had pushed the test data unknowingly to bitbucket from other testing branches.

PUSH Failed refs/head/ – pre-receive hook declined

So tried checking is that the same with other project repo’s and they weren’t having any issues.


My colleague noticed that when we cloned the project back locally, the size of the project was 110MB. So then we started cleaning the branches we merged earlier and active branches which are no more required. Once that cleaning is done for couple of branches we realized the size of the repo went drastically down from 2GB to 120MB. Then we tried to push the changes to my branch and it worked.

In my case I had a new repository, pushed a branch (‘UCA-46’, not ‘master’), rebased it, forcely pushed again and got the error. No web-hooks existed. I executed git pull --rebase as @ThiefMaster advised, had to rebase again and was able to push the branch. But that was a strange and difficult way.

Then I saw Git push error pre-receive hook declined. I found that my branch became protected. I removed protection and could forcely push again.

enter image description here

I got this when trying to push to a dokku instance. Turns out the disk was full on my server.

Ran: du -f

And result was:

Filesystem      Size  Used Avail Use% Mounted on
udev            476M     0  476M   0% /dev
tmpfs           100M  4.4M   95M   5% /run
/dev/xvda1      7.8G  7.4G  8.9M 100% /

For me Authorization on remote git server solve the problem. enter image description here

In my case, it’s because I accidentally added a giant file to my uncommitted push and I could not get rid of it no matter whatever pull or reset or rm I did after.

my dirty solution but workable solution is to rename the current directory, re-clone the directory to local and reflect the changes manually to the recloned local directory…

It does not sound good but works…

The error for me was that the project did not have any branches created, and my role was developer, so I could not create any branch, request that they give me the pertinent permissions and everything in order now!

A default branch (e.g. master) does not yet exist for your remote. So you first need to create master branch in the git remote server (e.g. creating a default file) then try to push all your existing local branches using this command:

git push -u origin --all

For me everything was working fine until Bitbucket automatically changed their policy today (April 21, 2020). This happens to align with a new feature recently introduced today called Workspaces, so I suspect it has something to do with that.

Workaround: I (as an Admin) followed the instructions to add the email address to Users in the UI (the email you are using can be found git config --list

enter image description here

I got this message while trying to delete a remote branch (git push origin –delete [branch-name]). The problem was that the branch was marked un-deletable in bitbucket.

I had permissions issue, after given the right permissions i was able to push the contents. I was pushing a existing project into a new git repo.

Specifying a node.js version can solve the problem like

  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "10.3.0"

Leave a Reply

Your email address will not be published. Required fields are marked *