我'我是git hooks的新手。我'我想确保在存储库中只推送/更新以BT开头的分支。因此无法更新master / current分支。我怎样才能实现这一目标?我想它应该是更新脚本的一部分,对吧?
答案 0 :(得分:2)
它可能是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