请告诉我如何拒绝创建分支,如果分支不是从主人创建的?
如果分支不是从主服务器创建的,我打算禁止提交,但是明确地确定向导不创建分支不起作用。
如果命令执行git checkout -b
,他写的 - 从HEAD创建。
答案 0 :(得分:0)
我应付了这项任务。实施如下:
我做了一个钩子预提交和强制命令,从命令git co -b new_branch_name master或git branch new_branch_name创建分支。
#!/bin/sh
current_branch=`git rev-parse --abbrev-ref HEAD`
result=`git reflog --date=local $current_branch | grep -F "Created from master"`
if test $current_branch = "master" ; then
echo "Cannot commit on master. Create branch and after merge with master!"
exit 1
fi
if [ -z "$result" ]; then
echo "ERROR! A branch is not created from the master! Create a branch with an indication of the parent branch."
exit 1
fi