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

天涯浪子 提交于 2019-12-25 08:57:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!