Ric*_*sen 20
git help hooks包含有关钩子的文档.update当Git即将创建/移动/删除引用时,将调用该钩子.每个引用都会调用一次进行更新,并给出:
如果钩子以非零退出代码退出,git则不会更新引用,并且用户将收到错误.
因此,要解决您的特定问题,您可以将以下内容添加到您的update钩子中:
#!/bin/sh
log() { printf '%s\n' "$*"; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
case $1 in
refs/tags/*)
[ "$3" != 0000000000000000000000000000000000000000 ] \
|| fatal "you're not allowed to delete tags"
[ "$2" = 0000000000000000000000000000000000000000 ] \
|| fatal "you're not allowed to move tags"
;;
esac
Run Code Online (Sandbox Code Playgroud)