参考链接:https://www.kancloud.cn/apachecn/gitlab-doc-zh/1949098
cat /opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.d/pre-receive
#!/bin/sh
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "$branch" = "master" ]; then
# Check if the commit message contains "Merge branch 'test'"
merge_test=$(git log -n 1 $newrev | grep "Merge branch 'test' into 'master'")
if [ -n "$merge_test" ]; then
echo "GL-HOOK-ERR: Merging the 'test' branch into 'master' is not allowed."
exit 1
fi
fi
done
exit 0