git 服务器端钩子 - 只会推送特定的分支
git server side hook - only specific branches will be pushed
我是 git 钩子的新手。我想确保只有以 BT 开头的分支才会被推送/更新到存储库。因此无法对 master / current 分支进行更新。我怎样才能做到这一点?我猜它应该是更新脚本的一部分,对吧?
它可能是一个 pre-receive
钩子。
#!/bin/bash
#sample
z40=0000000000000000000000000000000000000000
while read old new ref;do
#fail if it's not a branch or the name of the branch does not start with BT
if [ "${ref:0:13}" != "refs/heads/BT" ];then
echo "Error: not allowed to update $ref"
exit 1
fi
#deal with other cases if necessary
#create a ref, branch or tag
if [ "$old" = "$z40" ];then
:
fi
#delete a ref, branch or tag
if [ "$new" = "$z40" ];then
:
fi
done
我是 git 钩子的新手。我想确保只有以 BT 开头的分支才会被推送/更新到存储库。因此无法对 master / current 分支进行更新。我怎样才能做到这一点?我猜它应该是更新脚本的一部分,对吧?
它可能是一个 pre-receive
钩子。
#!/bin/bash
#sample
z40=0000000000000000000000000000000000000000
while read old new ref;do
#fail if it's not a branch or the name of the branch does not start with BT
if [ "${ref:0:13}" != "refs/heads/BT" ];then
echo "Error: not allowed to update $ref"
exit 1
fi
#deal with other cases if necessary
#create a ref, branch or tag
if [ "$old" = "$z40" ];then
:
fi
#delete a ref, branch or tag
if [ "$new" = "$z40" ];then
:
fi
done