How do I prevent renaming of a release branch? #180510
Replies: 7 comments
-
|
Hi there, |
Beta Was this translation helpful? Give feedback.
-
|
GitHub doesn’t have a direct “prevent rename” option. The only practical solution is monitoring via GitHub Actions / API and limiting admin permissions. |
Beta Was this translation helpful? Give feedback.
-
|
Good question. Unfortunately — as of now — there is no way via a built-in GitHub “Ruleset / Protected Branch” configuration to fully block renaming of branches. |
Beta Was this translation helpful? Give feedback.
-
|
Hey @HansdeGrootNice GitHub enterprise plans have support for commit metadata rules which can restrict branch names. Enterprise plans also support rule insights It is possible here with the configure ruleset, a team or role you are a member of might have bypass permissions which would not have applied the "restrict update" rule. |
Beta Was this translation helpful? Give feedback.
-
|
But GitHub does not support preventing renaming of branches via rulesets. |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
Short answer: You need to block "Deletions". In Git, "renaming" a branch is technically two operations happening behind the scenes: deleting the old branch reference and creating a new one. Therefore, if you prevent the branch from being deleted, you automatically prevent it from being renamed. Here is how to set this up using Branch Protection Rules: Go to your repository Settings. Click on Branches (on the left sidebar) -> Add branch protection rule. Branch name pattern: Enter the name of your branch (e.g., release or main). In the rule settings, ensure that "Allow deletions" is UNCHECKED. Note: By default, it is usually unchecked, but verify it explicitly. (Optional but recommended) Check "Do not allow bypassing above settings" if you want to apply this restriction even to repository administrators. Once this rule is active, anyone trying to rename that branch (via UI or CLI) will receive an error because the "delete" part of the rename operation will be blocked. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
I have set up Rulesets that restrict branch names and prevents deletion of release branches (release/*). That works well, but I can still rename the release branch to a bugfix branch and then delete it from the github.com frontend.
How can prevent that the release branches can be renamed?
I have already enabled "Restrict updates" on the ruleset, but that does not prevent renaming.
Beta Was this translation helpful? Give feedback.
All reactions