5个开发人员可以通过相同的ssh-account访问git-repository。我需要限制该回购的某些分支(生产,开发)的推送访问。如何使用git hooks实现简单的分支安全性?
首先,让我指出,在GIT中,可以使用一个push命令上载更多分支,在这种情况下,这可能会带来安全风险。为了避免这种情况,您应该使用类似于以下脚本的脚本(只是认为每个人都可以推送到第一个分支,但是第二个...将会为第一个分支进行授权-但第二个会完成?)
while read anotherOldrev anotherNewrev anotherRefname
do
newRefType="$(echo $anotherRefname | awk '{split($0,a,"/"); print a[2]}')"
if test "$newRefType" = "heads"
then
#branch
if test "$refname"
then
#branch, 2nd time, which means another branch
else
#branch, 1st time
oldrev=$anotherOldrev
newrev=$anotherNewrev
refname=$anotherRefname
fi
else
#tag
fi
done
另一方面,我不确定您是否可以在预接收挂钩中进行授权,因为您获得的所有信息都是旧参考,新参考及其名称... ...但是暂时更改名称只是一两个命令(http://git-scm.com/book/en/Customizing-Git)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句