Hello,
Is it possible to configure a repository so its not possible to merge in local, leaving as the only option merging by BB pull requests, where I can impose merge-checks?
Many Thanks.
You can't prevent local merges through Bitbucket configurations, but you could implement a Git hook to discourage any local merging. However, it's worth noting that Git hooks can be easily bypassed, so they serve more as a guideline than as a strict rule. That said, you can use Bitbucket's branch permissions to protect remote branches by disabling direct merges or writes. This allows merges to occur only via pull requests. By protecting the remote branch in this manner, you ensure that even if someone bypasses the local Git hook, Bitbucket will reject the push.
Hello,
Thanks for your answer.
To make sure I understand what you say. The configuration wold block any push to the remote if you made a local merge, but if it does not have a local merge you could push to the remote?
In that case, wich would be the configuration for setting this up?
Thanks.
Pablo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The idea is that using Bitbucket's branch permissions, you can protect certain branches, usually the remote origin/main branch. So locally, you clone the repo, branch from 'main' with a new branch named 'feature-A' and then push your 'feature-A' to remote and create a pull request to merge 'origin/feature-A into 'origin/main´.
By protecting the remote using Bitbucket branch permission users would still be able to clone your repo, checkout main and make a commit to local main. However it would block when trying to push to remote 'origin/main.
Now, if you want to, you could also have a git hook locally that would prevent someone from commiting to main locally. It would be more a way to catch it early and guide the user to use a branching and create a PR. It might not be worth the hassle of setting up hooks, if you only doing for this reason. As I already mentioned it is easy to bypass maliciously or because of a misconfiguration in the hooks. So you need to rely on the remote branch protection to effectively enforce this.
Hope this helps clarify it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Okey, I understand what you mean, but what i need, is to block merging in local to enforce the mergechecks I have on PRs.
So the developers can clone a repo and make changes in development, and in release, pushing them to the remote, but if they tried to merge development in release in local and then push it, block that push. So if they want to merge, they have to create a PR.
Is that possible?
Many thanks.
Pablo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that's possible - just use Bitbucket's branch permissions. In this case you would protect 'release' and allow write only via PRs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.