Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What's the difference between --squash & --squash --ff-only and when would I use one over the other?

Christian February 22, 2024

Bitbucket offers several merge strategies, amongst the Squash and Squash, Fast-forward only (docs); the latter was apparently introduced by BCLOUD-16338 .

I don't quite understand the difference between the two and when to use which one.

Here's what I do understand: 

If I have several commits on my feature branch, a squash will bunch them into one "unit" of changes, and it will then commit that unit of changes to the end of the target branch (e.g. "main"). There's no history of the feature branch, as I'd have with a merge commit.

The fast-forward option would usually make sure my feature branch is rebased (or branched off) the HEAD of the target branch. Merging that way means we're just pointing HEAD to the top of my feature branch. (My branch's individual commits become part of the target branch as individual units of change.)

From what I understand, --squash --ff-only will squash my changes, but only if the feature branch branched off from HEAD of the target branch? Is that right? (Not sure if order of flags is important here, or what the other way round would look like...)

If so, why do I need to --ff-only? It's not like --squash would commit anywhere other than the HEAD of the target branch; we're not somehow shuffling that commit in three commits ago and then rebase the target branch's latest commits on top of the squash commit... Why/when do I need it? What problem does it solve?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events