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 a merge has occurred. With Bitbucket Server 4.9, repository admins can choose which merge strategies to allow, and set a default merge strategy. And users can now choose a merge strategy from the merge dialog of each pull request.

Prior to Bitbucket Server 4.9, you could choose a merge strategy within the configuration file, but you would have to use the same merge strategy for all pull requests within a repository. And, changing merge strategies required you to restart the instance, which could cause disruption to sysadmins and downtime for end-users.

The merge strategy options are:

Merge commit
--no-ff
Always 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.

 

To configure merge strategies for a repository:

  1. In repository settings, select Pull requests.
  2. In the Merge strategy section, tick the box next to one or more merge strategies to determine which strategies are available to users when merging pull requests. 
  3. Once an option is enabled you can set it as the default merge strategy for that repository by clicking Set as default.

 

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.

Last modified on Feb 6, 2019

Was this helpful?

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