如何编写一个git钩子来限制写入分支? [英] How to write a git hook to restrict writing to branch?

查看:156
本文介绍了如何编写一个git钩子来限制写入分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制master分支对只有几个开发人员的写访问,同时允许其他人将所有内容全部推送到其他非主分支。想法是,开发人员会推送到其他分支,然后如果代码通过审查,审查人员会将其合并到主分支。



我很确定这可以用git commit hook很容易,但我不知道python,这看起来像是一个通用的问题,有人必须已经写过。你知道我在哪里可以找到这样的剧本吗?或者如果你有一个人躺在这里,请贴在这里,对于像我这样的懒惰的人。

解决方案

我认为可以使用这样的脚本,但它不是权利管理的正确位置,它应该是宁可在git服务器端完成。例如,在gitosis中,您可以在gitosis.conf文件中的gitosis-admin存储库中执行此配置。

挂钩管理的安全性很容易被破坏,只有服务器可以跟踪这件事情,请检查您的服务器的文档,以了解如何限制访问。


I'd like to restrict write access for the master branch to only several developers, while allowing others to pull everything and push to other non-master branches. Idea is that a developer would push to some other branch and then if code passes review, reviewer would merge it into the master branch.

I'm pretty sure that this can be easily done with a git commit hook, but I don't know python and this seems like such a generic problem, that somebody must have written it already. Do you know where I could find such a script? Or if you have one lying around, please paste it here, for lazy people like me.

解决方案

I think it could be possible to use such script but it is not the right place for rights management, it should be rather done on git server side. For example in gitosis you do this configuration in gitosis-admin repository in file gitosis.conf.

Security managed by a hook can be easily broken, only server can keep track of this things, please check documentation of your server for details how to restrict access.

这篇关于如何编写一个git钩子来限制写入分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆