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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.