Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: hook declined to update refs/heads/external_pub while pushing a branch

Tags:

git

Currently, I'm working on 'external_pub' branch. I made few changes in one file, added it, committed & then tried to push:

git push origin external_pub

But this was resulted into an error:

remote: error: hook declined to update refs/heads/external_pub
To ssh://XXX/testing.git
! [remote rejected] external_pub -> external_pub (hook declined)
error: failed to push some refs to 'ssh://XXX/testing.git'

Then I tried to push branch without any change to see what happens(just for isolating issue). I did following:

git reset --hard <commit_id> (to reset to last working sha commit)
git status

Above command showed:

# On branch external_pub
# Your branch is ahead of 'development' by 5 commits.
#
nothing to commit (working directory clean)

Then

git pull origin external_pub

It showed: your branch is already upto date

Then

git push origin external_pub

This time also, it showed the same error as above. Could you please help me to solve this?

like image 569
Alpha Avatar asked May 22 '13 11:05

Alpha


1 Answers

There's a git hook on the server that rejected the push. Quoting:

These scripts run before and after pushes to the server. The pre hooks can exit non-zero at any time to reject the push as well as print an error message back to the client; you can set up a push policy that’s as complex as you wish.

To find out why, you need to know what the hook does. Hooks are stored in hooks folder inside the git folder (on the remote end) - find the pre-receive hook or update hook and examine that.

like image 165
1615903 Avatar answered Oct 01 '22 07:10

1615903