git 限制某些 GitHub 用户合并分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9545503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Restrict certain GitHub users to merge branches
提问by HitOdessit
Is it possible to restrict certain git users to merge git branches on GitHub? I want to let users commit, pull and push changes in currentbranch, switch to another existing branch, but do not allow to merge branches. Is it possible on GitHub.com or standalone git repository?
是否可以限制某些 git 用户在 GitHub 上合并 git 分支?我想让用户在当前分支中提交、拉取和推送更改,切换到另一个现有分支,但不允许合并分支。是否可以在 GitHub.com 或独立的 git 存储库上使用?
采纳答案by iltempo
No. The only way to prevent things like this are git's internal pre-commit or update hooks. Those hooks get called before to push is accepted.
不。防止这种情况的唯一方法是 git 的内部预提交或更新挂钩。这些钩子在 push 被接受之前被调用。
GitHub itself doesn't support pre-commit or update hooks. Only web hooks are supported. But these are called after the push. So too late to prevent certain types.
GitHub 本身不支持预提交或更新挂钩。仅支持网络钩子。但是这些是在推送之后调用的。所以为时已晚,以防止某些类型。
回答by Michael Melanson
If your repository is under an organization on Github, you can add the developers to a read-access team. That way they can see and check out the repository but can't commit to it. They can also fork the repository, which lets them do their work in their fork then submit pull requests to get their work committed to the main repository.
如果您的存储库在 Github 上的组织下,您可以将开发人员添加到读取访问团队。这样他们就可以查看和签出存储库,但无法提交。他们还可以分叉存储库,这让他们可以在他们的分叉中完成工作,然后提交拉取请求以将他们的工作提交到主存储库。
You can then grant write access to only certain developers who will be in charge of reviewing and merging pull requests.
然后,您可以仅向负责和合并拉取请求的某些开发人员授予写访问权限。
回答by sebastian serrano
bitbucket supports permissions per branch which would help you prevent merges to your branches. I miss that feature on github
bitbucket 支持每个分支的权限,这将帮助您防止合并到您的分支。我想念 github 上的那个功能
回答by Sailesh
NO
不
You may be thinking this because of the "Merge Changes" button of Github on a Pull Request. But that is just a convenience thing. For example, if there are conflicts, that button is disabled, and you'd have to manually merge changes on your machine and Push them to Github.
你可能会这么想是因为 Github 上的“合并更改”按钮对拉取请求。但这只是一个方便的事情。例如,如果存在冲突,该按钮将被禁用,您必须在您的机器上手动合并更改并将它们推送到 Github。
So, if a user can Push changes to a branch, how would you stop him to merge another branch on his machine, and Push it? Since that kind of restriction is not there in Github afaik, you won't be able to accomplish this.
那么,如果用户可以将更改推送到一个分支,您将如何阻止他在他的机器上合并另一个分支并推送它?由于 Github afaik 中没有这种限制,因此您将无法完成此操作。
Oh, but you can always ask your users politely not to merge branches ;).
哦,但是你总是可以礼貌地要求你的用户不要合并分支;)。
回答by Philip Durbin
I'm not sure what "standalone git repository" means, but gitolite might give you what you want:
我不确定“独立的 git 存储库”是什么意思,但 gitolite 可能会给你你想要的:
"Example 2, one repo, but different levels of access to different branches and tags for different developers" -- http://sitaramc.github.com/gitolite/why.html
“示例 2,一个存储库,但不同开发人员对不同分支和标签的访问级别不同” ——http://sitaramc.github.com/gitolite/why.html
See also Git: Teamwork across branches without Push Permission