Choosing merge strategy for Pull Request

Marian Grigoras October 30, 2013

Is it possible to choose the merge strategy on a Pull Request?

There is some reference to such options in the stash-config.properties file in https://jira.atlassian.com/browse/STASH-2857 and https://jira.atlassian.com/browse/STASH-2810, but they are not available in the current doc https://confluence.atlassian.com/display/STASH/Stash+config+properties

Is this option still active in 2.8.2? What are the possible values?

Thanks, Marian

4 answers

2 accepted

4 votes
Answer accepted
cofarrell
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.
October 30, 2013

Hi Marian,

We definitely haven't removed the option. I'm not sure why the doc doesn't mention them. The valid options are (still):

  • ff - allows fast-forward merges but will create merge when necesssary
  • ff-only - will never create merge commits; all merges must be fast-forward or a MergeException will be thrown
  • squash - collapses all the incoming commits into a single commit directly to the target branch and will never create a merge

Cheers,

Charles

Marian Grigoras October 30, 2013

Hi Charles,

thanks for the fast answer.

https://jira.atlassian.com/browse/STASH-2857 mentions "no-ff" being the default option. Is this correct and also a valid value?

Thanks, Marian

cofarrell
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.
October 30, 2013

Hi Marian,

Apologies for not mentioning 'no-ff' - it is the other value, and the default.

Charles

Bryan Turner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2013

Stash 2.9 will add:

  • squash-ff-only - As with "squash", collapses all the incoming commits into a single commit directly to the target branch, never creating a merge, but does so only if the source branch is fast-forward. If not, a MergeException will be thrown.

This basically combines the "squash" and "ff-only" options, as its name suggests.

1 vote
Answer accepted
Clément Séveillac August 31, 2016

It's even clearer (accessible from the UI) and better since Bitbucket 4.9, released yesterday wink https://confluence.atlassian.com/bitbucketserver/checks-for-merging-pull-requests-776640039.html#Checksformergingpullrequests-strategies

2 votes
paulwatson
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2013
0 votes
Sarath February 20, 2019

I want to change the default value no-ff to squash for a project in v4.8.3

From the documentation I see that I need to modify "plugin.bitbucket-git.pullrequest.merge.
strategy.KEY.slug=no-ff". 

Can anyone help me how do I that?

Bryan Turner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2019

@Sarath

The best thing to do would be to upgrade to a more recent version of Bitbucket Server, which will allow you to configure the strategy via the UI. Bitbucket Server 4.8 is end of life, and no longer receives bugfixes or security fixes and is no longer eligible for support beyond assistance with an upgrade to a supported version.

In order to change the setting on Bitbucket Server 4.8, you will need to have terminal access to the server on which Bitbucket Server runs (SSH access, console access, etc.) to be able to edit a configuration file on disk. If you do not have access to the server, it is not possible to change the configuration. You'll need to get in touch with an administrator for your organization who does have such access and ask them to make the change for you. (Or, again, better yet, ask them to upgrade your instance.)

If you have server access, you'll need to edit "bitbucket.properties", which will be in "$BITBUCKET_HOME/shared". There won't be an existing line that looks like the example you pasted. Instead, you're intended to substitute your actual project key where "KEY" is, and your actual repository slug where "slug" is and add a new line to the configuration. For example, given a project key of "QA" and a repository slug of "config-example", the property would be "plugin.bitbucket-git.pullrequest.merge.strategy.QA.config-example". If you want to apply the configuration change to all repositories in a given project, leave off the repository slug: "plugin.bitbucket-git.pullrequest.merge.strategy.QA".

You'll add a line with that key, and your desired strategy, save the file and restart Bitbucket Server. Changes are not picked up until the application is restarted.

Valid strategy values are: "ff", "ff-only", "squash", "squash-ff-only" and "no-ff". Setting "no-ff" does nothing, since it's the default strategy the system is already using.

Best regards,
Bryan Turner
Atlassian Bitbucket

Sarath March 21, 2019

hi @Bryan Turner 

Sorry I didn’t get back to you sooner. I requested them to upgrade complete atlassian stack. I only have read access to server, So I will req. respective one to modify the change  and schedule for restart until we get the new BB and JIRA.

Just to summarize, is it possible to have the “Squash” merge option in addition to the existing “Merge commit” option that we currently have today? or it would replace default with squash?

Bryan Turner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2019

Prior to Bitbucket Server 4.9, it is not possible to configure multiple strategies. Setting on the strategy via `bitbucket.properties` will _replace_ the default "no-ff" strategy with whatever strategy you configure, and all pull requests will be merged that way.

In Bitbucket Server 4.9 and newer, you can enable multiple strategies with one set to be used by default. If only a single strategy is enabled, it will be used automatically for all pull requests. If multiple are enabled, a dropdown will be displayed on the pull request merge dialog, with the default strategy selected initially, and the merger can select the strategy to use.

Best regards,
Bryan Turner
Atlassian Bitbucket

Like Sarath likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events