I can enforce a merge strategy per project, but we need to change the merge strategy at the branch level. We can allow multiple strategies, but the person who does the merge has to be diligent in selecting the correct one. This is most problematic when merging a long-running development branch into our master branch. We squash PR's to the development branch, but we don't want the PR from development to master to be squashed. Relying on the person who is charged with merging from development to master to make that proper choice has not worked out so well for us.
How can we enforce a merge strategy on a per-branch basis?
Our free add-on, Control Freak for Bitbucket Server, might be able to help you with this specific situation.
For the repo in question, set the following config:
Repo --> Settings --> Control Freak
Require Squashed Merges Into:
[x] Default [x] Development [x] Production [x] Release Branches
And then click "Save Settings."
The neat thing about this setting is that while it forces squashes for all merges coming into those branches (based on the repo's branching model), merges *between* those branches do not require squashes.
You might also want to set Control Freak's "Require Fast-Forwardable Merges Into:" setting for the same branches, to force a squash + rebase workflow.
It works particularly well with our other paid add-on, Bit-Booster Rebase Squash Amend, since that one puts a "Squash" button right on the pull-request screen.
Email us any time at: email@example.com.
Note: there's a bit of an implied assumption in the Control-Freak solution for this problem. The implied assumption is that "--ff" merge is your default merge option (not "--ff-only"), since it will nicely accept the "fast-forward" on the squash, but nonetheless allow the regular merge for the longer lived branches.
BUT if you've set "--ff" to your default merge option, then you really want to disable foxtrot merges as well, because "--ff" merges and foxtrots make a mess of the commit graph.
LUCKILY Control-Freak has that covered:
Block Foxtrot Merges On:
[x] Default [x] Development [x] Production [x] Release Branches [x] Hotfix Branches
[x] Bugfix Branches [x] Feature Branches [x] All Others
(We recommend enabling this block for all branches).
Any built in support for this in Bibucket Server? We also need to prevent squashes to certain branches, as squashes of branches that contain squashes are REALLY bad and cause of lots of merge headaches.
It's really the only deficiency in Bitbucket that we come across.
Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events