如何在 GitHub 中禁用拉取请求?

How to disable pull requests in GitHub?

我正在尝试了解如何在 github 中禁用 "pull requests"。

问题一: 我们正在尝试使用变基工作流程,这意味着如果不是快速推进,使用拉取请求可能是有害的。 一种解决方案:为我想禁用拉取请求的分支设置分支权限。或者将我作为审阅者添加到 master 中的任何内容。

问题二: 那么问题来了,我可以在 github 中设置分支权限吗??我可以将自己添加为任何想要进入 master 的更改的审阅者吗?

问题三: Github 确实删除了预接收挂钩,那么我如何在源到达服务器之前执行任何强制措施?预提交挂钩可以做到,但同时也很痛苦。

我在这里问过类似的问题:Commit message hook on github

似乎 github 可能对合并工作流甚至 git-flow 有用,但它可能很难维护 rebase 工作流,这是一个合理的假设吗?

我可以将 atlassian Stash 视为 rebase 工作流的更好工具吗?

您无法使用 Github 设置分支权限。但是,如果您是唯一拥有推送权限的人,则不必禁止创建拉取请求:您可以手动变基并推送它们。

我满足您需求的工具是 Gerrit。它是一个开源软件,就像一种围绕 Git 的包装器。它主要是一个代码审查软件。但它也将允许您定义每个分支的权限。

但是,与 Github 的不同之处在于,您可能必须自己托管它。

我制作了一个工具,可以在拉取请求打开时自动关闭它们。

https://nopullrequests.appspot.com

编辑:该工具不再有效。

How to disable pull requests in GitHub?

自 2021 年 11 月起,现在可以:

Allow bypassing required pull requests

This is a good practice, but you may want to make exceptions to this rule for specific people and teams.
For example, if you have an automated process that calls GitHub APIs to make changes in a repository, you may want to permit that automation to make changes without creating a pull request.

Now, when you require pull requests and their related protections for a branch, you can specify people and teams who should be free from those requirements.

As shown in the image below, select Allow specific actors to bypass pull request requirements. Then, search for and select the people and teams who should be allowed to bypass the requirements.

For more information, visit Managing a branch protection rule.


2021 年之前,这是不可能的:


Armin Sebastian suggests in GitHub issue 1191

I've made a new app that immediately closes and locks new and existing issues or pull requests and also supports posting a comment and labeling.
It is perfect for forks and mirrors, and you can configure it to your liking

dessant/repo-lockdown,其中 .github/lockdown.yml 包括

# Lock issues and pull requests
lock: true

# Limit to only `issues` or `pulls`
# only: pull

其他解决方法:

请注意(考虑到 2015 年 1 月的 OP 日期):

自 2016 年 10 月起,您可以 dismiss a review

However, this requirement can sometimes block your team’s progress without good reason.
If someone leaves a review that requests changes and then goes on vacation or runs into computer problems, your pull request could be blocked for days, even after you’ve addressed the reviewer’s concerns.

This will unblock your pull request, freeing you up to merge it!

根据GitHub支持是不可能的

我在 2018 年 2 月问过支持@github.com 是否可以删除 Pull Requests 选项卡,@nickcannariato 的回复是:

Thanks for writing in! We've definitely heard some users requesting this feature over the last couple of years, and it's currently on our feature request list. I can't make any promises about if or when we may add this ability in the future, but I'll add your +1 to that feature request so the team can see it.

确认不可能。

对 de-facto 个跟踪器的请求: