Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

I would like to enforce a merge strategy on a per-branch basis in Bitbucket

Chris Gamache March 30, 2018

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?

2 answers

1 vote
mark_gillespie July 14, 2020

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.

1 vote
Julius Davies _bit-booster_com_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2018

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:

Override: Yes

[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.

Chris Gamache March 30, 2018

This looks *really* good. Demo-ing it right now.

I'm optimistic that it will get us where we need to be. Thanks vv much!

Julius Davies _bit-booster_com_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2018

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: support@bit-booster.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).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events