0

I would like to use git pre-push hook only for that cases when I added a new tag. Can I somehow analyze the push for this information?

Andrii
  • 43
  • 4

1 Answers1

0

As described in the Git githooks documentation for pre-push:

Information about what is to be pushed is provided on the hook’s standard input with lines of the form:

<local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF

For instance, if the command git push origin master:foreign were run the hook would receive a line like the following:

refs/heads/master 67890 refs/heads/foreign 12345

So when a tag is pushed there should be a line starting with refs/tags/.

Check for this and execute your hook conditionally.

Community
  • 1
  • 1
AnimiVulpis
  • 2,670
  • 1
  • 19
  • 27