Pull request merge strategies

Still need help?

The Atlassian Community is here for you.

Ask the community

Git merge strategies affect the way the Git history appears after merging a pull request. 

With Bitbucket Server, you can choose which merge strategies to allow, and enable one or more merge strategies for all repositories in a project or for an individual repository. You can also allow users to choose a merge strategy from the merge dialog when they create a pull request.

This page describes how to configure which merge strategies are available to your users, and briefly describes the merge strategies available.

On this page:

Merge strategies

Bitbucket Server comes with only one merge strategy enabled by default, but all merge strategies can be enabled (or disabled) at the project level for all repositories in a project or for individual repositories, provided merge strategies for a repository are configured to inherit project settings.

The merge strategies available in Bitbucket Server are:

  • Merge commit (--no-ff) DEFAULTAlways create a new merge commit and update the target branch to it, even if the source branch is already up to date with the target branch.
  • Fast-forward (--ff): If the source branch is out of date with the target branch, create a merge commit. Otherwise, update the target branch to the latest commit on the source branch.
  • Squash (--squash): Combine all commits into one new non-merge commit on the target branch.
  • Fast-forward only (--ff-only): If the source branch is out of date with the target branch, reject the merge request. Otherwise, update the target branch to the latest commit on the source branch.
  • Squash, fast-forward only (--squash --ff-only): If the source branch is out of date with the target branch, reject the merge request. Otherwise, combine all commits into one new non-merge commit on the target branch.

Change the merge strategy for a single pull request

Which merge strategies can be used is determined by the merge strategies enabled by your project or repository admins. 

To change the merge strategy for a specific pull request:

  1. When merging a pull request, click the default merge strategy in use, then select a new one.
  2. Add a comment (if applicable), the click Merge.

The Merge pull request dialog

Configure merge strategies for all repositories in a project

Enabling a merge strategy at the project level allows users to choose that merge strategy when merging pull requests for all repositories in a project, unless a repository is configured to use custom settings instead.

To enable (or disable) merge strategies for all repositories in a project (requires project admin permissions):

  1. Go to Project settings > Merge strategies.
  2. Click the toggle by a merge strategy to enable (or disable) it.
  3. Click Save.

 

Users can now choose any of the merge strategies you enabled when they merge pull requests from the repositories in the project.

Configure merge strategies for an individual repository

Enabling (or disabling) a merge strategy at the repository level allows users to choose that merge strategy when merging pull requests created in that repository. Configuring merge strategies at the repository level requires you to override merge strategies configured at the project level. If you have not configured merge strategies for an individual repository it will inherit the merge strategies enabled at the project level.

To enable (or disable) merge strategies for a single repository (requires repository admin permissions):

  1. Go to Repository settings > Merge strategies.
  2. In the Project settings inheritance section, select Use custom settings.
  3. Click the toggle by a merge strategy to enable (or disable) it.
  4. (Optional) Once a merge strategy is enabled you can set it as the default merge strategy for that repository by hovering next to the toggle and clicking  Set as default.

  5. Click Save.

 

Once set, any changes made to merge strategies at the project level will be ignored for this repository because it was changed independent of the project configuration.

Last modified on Jul 7, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.