Restrict branch creation #9620

Closed
opened 2025-11-02 08:44:42 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @PaulBol on GitHub (Sep 27, 2022).

Feature Description

I had the same question that someone asked for GitHub here:

I was wondering if there is anyway to restrict the branch creation in GitHub Gitea. I have 4-5 branches created for a repo and would like to maintain it that way.

The idea is that developers work in their own repositories and merge into the main repository and branch through pull requests. Without the option of accidentally or willingly creating new branches in the main repository.

The answer given is that as of May 2022 GitHub has a branch protection setting named Restrict pushes that create matching branches. Adding a rule * will prevent the creation of any new branch.

It would be awesome if Gitea could support the same.

Screenshots

grafik

Originally created by @PaulBol on GitHub (Sep 27, 2022). ### Feature Description I had the same [question that someone asked for GitHub here](https://stackoverflow.com/questions/61811708/github-new-branch-creation-restriction): > I was wondering if there is anyway to restrict the branch creation in ~~GitHub~~ *Gitea*. I have 4-5 branches created for a repo and would like to maintain it that way. The idea is that developers work in their own repositories and merge into the main repository and branch through pull requests. Without the option of accidentally or willingly creating new branches in the main repository. The answer given is that as of May 2022 GitHub has a branch protection setting named *Restrict pushes that create matching branches*. Adding a rule `*` will prevent the creation of any new branch. It would be awesome if Gitea could support the same. ### Screenshots ![grafik](https://user-images.githubusercontent.com/38468549/192456975-074b10c2-a79a-454b-bfb8-34dc7400600d.png)
GiteaMirror added the type/proposaltype/feature labels 2025-11-02 08:44:42 -06:00
Author
Owner

@lafriks commented on GitHub (Sep 27, 2022):

Duplicate of #2529

@lafriks commented on GitHub (Sep 27, 2022): Duplicate of #2529
Author
Owner

@PaulBol commented on GitHub (Sep 27, 2022):

I saw issue #2529 but thought it was a different suggestion.

My understanding was that with the implementation of #2529 newly created branches automatically fall under branch protection if matching the wildcard once created. I now assume that pull request #20825 can also be used to prevent pushes that would create branches matching the wildcard. That will be great!

@PaulBol commented on GitHub (Sep 27, 2022): I saw issue #2529 but thought it was a different suggestion. My understanding was that with the implementation of #2529 newly created branches automatically fall under branch protection if matching the wildcard once created. I now assume that pull request #20825 can also be used to prevent pushes that would create branches matching the wildcard. That will be great!
Author
Owner

@lafriks commented on GitHub (Sep 27, 2022):

yes you could use * to protect all branches once wildcard branch protection is implemented

@lafriks commented on GitHub (Sep 27, 2022): yes you could use `*` to protect all branches once wildcard branch protection is implemented
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9620