Preventing Recreation of Master Branch



Request for GitHub to prevent re-creation of Master branch

Proposal

We completed our analysis of the GitHub native renaming tool.  You can see my full set notes and evaluation criteria at https://samvera.atlassian.net/wiki/x/AYBcJg .  There are only two major pieces of feedback I would like to provide.

 

-----------------------------------

Able to recreate master

-----------------------------------

The biggest concern we have is that the master branch can be republished to GitHub which has the potential to cause a lot of problems in such a large community with many committers.  There can be confusion with new PRs set to merge in to the republished master branch.

 

Something GitHub can do that would give us the tools we need to prevent this is to add an option to block creation of branches that match the ‘master’ pattern.  For example, the process could be…

 

  • Create new branch rule at  Settings -> Branches -> Add rule

  • Branch name pattern: master

  • Under Rules applied to everyone including administrators, add rule ‘Block creation’ with description something like ‘Do not allow branches with the matching pattern to be published to GitHub.’

 

-----------------------------------

Forwarding of missing to renamed branch

-----------------------------------

This is less important if the first area is addressed.  What I noticed is that after the rename, all URLs that are directed to master were forwarded to the same path under the main branch.  This is great.  

 

The problem comes in if a branch with the old name is created.  The forwarding no longer happens.  This is understandable and in some scenarios might even be desirable.  But it is again a potential pitfall when working in a large community.  If we are able to block the creation of certain branches, this would not pose a significant problem.

 

We completed our analysis of the GitHub native renaming tool.  You can see my full set notes and evaluation criteria at https://samvera.atlassian.net/wiki/x/AYBcJg .  There are only two major pieces of feedback I would like to provide.

 

-----------------------------------

Able to recreate master

-----------------------------------

The biggest concern we have is that the master branch can be republished to GitHub which has the potential to cause a lot of problems in such a large community with many committers.  There can be confusion with new PRs set to merge in to the republished master branch.

 

Something GitHub can do that would give us the tools we need to prevent this is to add an option to block creation of branches that match the ‘master’ pattern.  For example, the process could be…

 

  • Create new branch rule at  Settings -> Branches -> Add rule

  • Branch name pattern: master

  • Under Rules applied to everyone including administrators, add rule ‘Block creation’ with description something like ‘Do not allow branches with the matching pattern to be published to GitHub.’

 

-----------------------------------

Forwarding of missing to renamed branch

-----------------------------------

This is less important if the first area is addressed.  What I noticed is that after the rename, all URLs that are directed to master were forwarded to the same path under the main branch.  This is great.  

 

The problem comes in if a branch with the old name is created.  The forwarding no longer happens.  This is understandable and in some scenarios might even be desirable.  But it is again a potential pitfall when working in a large community.  If we are able to block the creation of certain branches, this would not pose a significant problem.

 

 

Response: Suggested creating a new master branch with no shared history and a single README file. This broke auto-forwarding of links to master to the new main branch. They will consider our proposal. No indication of timing.


Use CircleCI to prevent creation of master branch

 

https://github.com/rotated8/branch-tests/blob/main/.circleci/config.yml#L15