简体   繁体   中英

Can I use git pre-push hook only for that case when I made a new tag?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM