sanjay Paudel
sanjay Paudel

Reputation: 39

Branch Protection Rule on GitHub

Is it possible to enable branch protection rules at the organisation level in GitHub so that all repositories that are part of that organisation inherit these rules for the applied branches. Right now it's really a hassle to enable those same set of rules on a per repo basis for same set of branches. How can we achieve this?

Right now it's really a hassle to enable those same set of rules on a per repo basis for same set of branches.

Upvotes: 2

Views: 2767

Answers (2)

Jacob
Jacob

Reputation: 587

Yes, you can set rules at the Organization level. The rules further allow you to select which Repos to apply them to and what branches on each repo.

Image of the GitHub Organization Settings page showing the Rules option.

This feature may be restricted to certain repo and subscription types:

Rulesets are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see "GitHub’s plans." -- GitHub Docs - About rulesets

Upvotes: 1

timmeinerzhagen
timmeinerzhagen

Reputation: 1011

There is no organization level default option to set a branch protection for all repositories in an org.

If this is something you don't want to repetitively do by hand, you can take a look at the GitHub API for Branch Protection. That way you can run a short script whenever you setup a new repo or have a job run periodically that sets and confirms the branch protection for all repos in the org at once.

Upvotes: 0

Related Questions