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

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:

  • Git: How to remove file from historical commit?
  • Showing a file tree view of a commit in tig
  • git: get effective GIT_DIR, if current dir is a working tree subdir and $GIT_DIR is unset
  • Creating GitHub Pages Repo
  • XCode, Git and MediaTemple (gs)
  • Unstaged changes left after git reset --hard
  • 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)


    git pull origin external_pub

    It showed: your branch is already upto date


    git push origin external_pub

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

  • git eclipse synchronize workspace shows too many incoming changes due to line endings
  • Github repository user group definition
  • Why does GIT not use the core.editor and commit.template configuration values when running from the bash command prompt?
  • How does SVN store identical text files in different sub-directories
  • How to restore git master, which was replaced by another master
  • Squash all commits with commit messages that match a certain pattern
  • 2 Solutions collect form web for “error: hook declined to update refs/heads/external_pub while pushing a branch”

    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.

    In OSX its usually caused by missing GEM’s between brew ruby install and Apple ruby 2.0 (default).

    An include ‘require json/ext/parser’ or similar add-on is not found and exceptions at the require point.

    Git Baby is a git and github fan, let's start git clone.