Home > Blockchain >  How to block local merges on a specific branch
How to block local merges on a specific branch

Time:12-17

I have the "production" branch and I need to block merges to this branch, which can only be done by merge request.

The repository is in bitbucket, I already configured the branch restriction, leaving only the admin user as the only user to approve and merge branches. Operating from the bitbucket everything works fine. And there are the other users with read or write privileges.

The problem is that if from my local configured as a low-privileged user, I commit to a new branch and merge that same one to the "production" branch, it does so without problems and all the bitbucket configuration is skipped.

In short, I need the production branch to be locked to merges and commits. That can only be done through pull requests.

CodePudding user response:

Branch protection features in git hosting services (BitBucket, GitHub, GitLab, etc) protect against pushes to protected branches that would impact the repository shared with other users. There is no way to enforce branch protection on a user's local clone of a repository, due to the way git works. However as soon as they attempt to push commit forbidden by the branch protection rules on your hosting service, they will get an error.

  • Related