Choosing merge strategy for Pull Request

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

3 votes
Accepted answer

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

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

Hi Marian,

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

Charles

Bryan Turner Atlassian Team Oct 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
Accepted answer

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

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 Wednesday

@Sarath Pulipati

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,960 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you