加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 综合聚焦 > Linux > 正文

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

发布时间:2021-02-21 03:44:12 所属栏目: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

(编辑:商洛站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读