在 git Push 上需要带注释的标签并拒绝轻量级标签

Sma*_*ery 5 git git-tag

是否可以在 git 存储库上设置不允许将轻量级标签推送到其中的策略?

Von*_*onC 4

Git hook 页面提到:

\n\n
\n

默认更新挂钩,当启用 \xe2\x80\x94 且hooks.allowunannotated配置选项未设置或设置为 false \xe2\x80\x94 时,会阻止推送未注释的标签。

\n
\n\n

这又引用了克里斯·约翰森在评论中提到的内容。update.sample

\n\n
case "$refname","$newrev_type" in\n    refs/tags/*,commit)\n        # un-annotated tag\n        short_refname=${refname##refs/tags/}\n        if [ "$allowunannotated" != "true" ]; then\n            echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2\n            echo "*** Use \'git tag [ -a | -s ]\' for tags you want to propagate." >&2\n            exit 1\n        fi\n        ;;\n
Run Code Online (Sandbox Code Playgroud)\n