git pre-push hook, don't run if is --tags

Viewed 2759

I have a prepush hook that tests my code, however, it also runs when I do a git push --tags. Is there any way to avoid this?

Maybe there's some way to check if its a regular push or if its a --tags push?

Update - These are the only arguments I was able to find:

  • $1 is the name of the remote
  • $2 is url to which the push is being done
4 Answers

You are looking for the --no-verify flag. So:

git push --tags --no-verify

This is what git help push tells you about that flag:

       --[no-]verify
           Toggle the pre-push hook (see githooks(5)). The default is --verify, giving the hook a chance to prevent the push.
           With --no-verify, the hook is bypassed completely.
Related