Fast-forward merges in Bitbucket Cloud – and by default, if you like

Imagine this scenario: your code’s ready to go, your teammates have approved your pull request, and the builds are green. Now you just need to merge your feature branch into master, but you have a choice to make: which merge strategy should I use?

Natively, Git offers several merge strategies. In Pull Request Merge Strategies: The Great Debate, fellow Atlassian Nicola Paoluicci presents the merge strategies that are most popular amongst teams, along with the pros and cons of each option.

As Nicola’s post mentioned, teams at Atlassian lean towards using explicit merge commits:

what is a merge

Some teams prefer to forego merge commits to maintain a linear commit history. Bitbucket already supports squash on merge, which results in a single commit on the destination branch containing your merged changes. The result? A tidy list of commits – one for each merge:

squash on merge

However, squashed merges can be undesirable in some cases: you may want to maintain a linear commit history without squashing to a single commit. For example, if your feature includes an API change and a front-end change, you might prefer to keep those changes as separate commits – but you still want a linear history without merge commits.

Fast forward merge strategy

That’s why we’ve added fast forward as an available merge strategy. fast forward merge will apply your source branch commits to the destination branch by moving the HEAD of the destination branch to the HEAD of your source branch (if there are no other commits on the destination). All without a merge commit. This maintains a linear history while keeping all of the commits from your source branch intact:

fast forward merge

To use the new fast forward option the next time you merge, select it as your desired Merge strategy in the merge dialog:

merge pull request

Default merge strategy repository setting

As a matter of team policy, some teams would prefer to always use the same strategy. To make this easier, we’ve introduced a default merge strategy repository setting.

This setting determines which merge strategy should pre-populate by default when your team members merge a pull request in Bitbucket. From your repository Settings, you can find this option on the Merge strategies page under Workflow.

merge strategies

We hope you enjoy! If you have any feedback to share regarding this feature, tweet us @Bitbucket. Happy merging!

Try Bitbucket Cloud