问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/38736656/can-i-use-git-pre-push-hook-only-for-that-case-when-i-made-a-new-tag