在我的本地gitup repo中,我设置了2个变量和一个echo语句
git config --local --add hooks.allowdeletebranch true
git config --local --add hooks.denycreatebranch false
然后在本地repo更新我的钩子: .git / hooks / update
设置完之后,我进入了文件和代码的case语句部分,我找到了 branch 和 delete branch 的注释,复制在下面
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
echo "Creating Jenkins Job for Branch."
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
echo "Deleting Jenkins Job for Branch."
;;
你看到我添加了两个echo语句:
echo "Creating Jenkins Job for Branch"
echo "Deleting Jenkins Job for Branch"
似乎现在一切都已到位,但是当我在本地创建一个新的分支并设置在上游时,我想我会看到一个echo语句,但我不知道。我也做了第一次提交和推送。
我当时认为对.git的修改可能实际上没有被触发,因为服务器上没有设置挂钩?如果是这种情况,我只是添加.git / hooks / update到我的跟踪,这样服务器就有了它的副本?