In a GitHub organization, you may find yourself in need of repository admins. While this can be challenging regarding governance, one thing that we usually don’t want is for our repositories to be renamed. Today, I will show you how to prevent this using rulesets.
Rulesets is a GitHub functionality that protects our branches and tags, regarding who and what is allowed in our repositories. You can learn more about rulesets in the GitHub Docs.
To create a new ruleset, go to Organization / Settings / Rulesets / New Ruleset / New branch ruleset.
We can manage who can bypass this ruleset based on Roles, Teams or GitHub Apps.
There is an option while creating a new branch ruleset that can prevent the renaming of all repositories or just the ones based on an fnmatch syntax.
This option will prevent the renaming of every repository.
I have removed every other option on Branch protections in this ruleset.
With this ruleset enabled, if I try to rename the repository without a role to bypass, I see the error message “Name can’t be changed on a repository protected by a ruleset”.
GitHub’s rulesets can prevent repository renaming in your organization and many other scenarios. By creating a new branch ruleset and managing bypass permissions, you can ensure repository governance. This helps maintain consistency and order.
Remember, effective governance is about setting and adhering to rules. With rulesets, you’re closer to this goal.