Aske Olsson <> writes:

> If the script .git/hooks/pre-push exists and is executable it will be
> called before a `git push` command, and when the script exits with a
> non-zero status the push will be aborted.
> The hook can be overridden by passing the '--no-verify' option to
> `git push`.
> The pre-push hook is usefull to run tests etc. before push. Or to make
> sure that if a binary solution like git-media, git-annex or git-bin is
> used the binaries are uploaded before the push, so when others do a
> fetch the binaries will be available already. This also reduces the
> need for introducing extra (git) commands to e.g. sync binaries.
> Signed-off-by: Aske Olsson <>
> ---
> ...
> +[[pre-push]]
> +pre-push
> +~~~~~~~~
> +
> +This hook is invoked by 'git push' and can be bypassed with the
> +`--no-verify` option. It takes no parameter, and is invoked before
> +the push happens.
> +Exiting with a non-zero status from this script causes 'git push'
> +to abort.
> ...
> + if (!no_verify && run_hook(NULL, "pre-push")) {
> + die(_("pre-push hook failed: exiting\n"));
> + }

NAK, at least in the current form.  At least the system should tell
the hook where it is pushing and what is being pushed.

After working on my notebook, I may want to push to my desktop
machine first to test it, without having to test locally on an
underpowered CPU, but when I am publishing the end result to the
wider world, I do want to test the result beforehand.  Without
"where am I pushing", the hook would not help me to enforce testing
only for the latter.

A lazy "git push" without any other argument may be configured in my
repository to push its "maint", "master", "next" and "pu" branches
to the public repository.  I may say "git push origin +pu", while on
one of the topic branches, to push only the "pu" branches out before
I am confident that the other branches I'll eventually publish are
ready (it is more likely that I may even *know* they are broken and
do not pass the test in such a case, and that is why I am pushing
only "pu" out).  I'd want to run tests only on 'pu' in such a case.
Without "what am I pushing", the hook would not be able to help me
doing that, either.

Besides, there are five valid reasons to add a new hook to the
system, but your version of pre-push does not satisfy any of them:

It is more like "to always cause an action before running a git
operation locally," so you can even write

    cat >$HOME/bin/git-mypush <<\EOF
    run test || exit
    exec git push "$@"
    chmod +x $HOME/bin/git-mypush

and then can run "git mypush" instead of adding this hook.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to