首页 Linux linux – 如何阻止在远程主机上分支

linux – 如何阻止在远程主机上分支

有没有办法阻止代码推送直接掌握?我尝试在.git / hooks / update中添加一个脚本: #!/bin/shif [ $USER != git-repo-admin ];then if [ $1 == refs/heads/master ]; then echo Manual pushing to this repo is restricted e

有没有办法阻止代码推送直接掌握?我尝试在.git / hooks / update中添加一个脚本:

#!/bin/sh
if [ $USER != "git-repo-admin" ];
then
  if [ "$1" == refs/heads/master ];
  then
    echo "Manual pushing to this repo is restricted"
    exit 1
  fi
fi

但这不行 – 每个人都可以推.我只想允许特定用户推送以阻止他人.

解决方法

原始脚本是完美的,我只需要将其从.git / hooks / update.sample重命名为远程服务器上的.git / hooks / update,并确保它是可执行的.

#!/bin/sh
if [ $USER != "git-repo-admin" ];
then
  if [ "$1" == refs/heads/master ];
  then
    echo "Manual pushing to this repo is restricted"
    exit 1
  fi
fi

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/zhonghe/fwq/linux/20210220/17474.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部