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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

git flow merge --no-ff

Hi all,

For what I've learn about git-flow, when someone finish a feature (or a hotfix, is the same), git flow should be merge the feature branch into develop (and also into master in case of hotfix branch) using --no-ff options.

Using git-flow with SourceTree (all version, Windows and Mac), this does not happen.

When I click on "finish feature" (for example) the next window show me a checkbox with "rebase on development branch" label, that seems a choise for what SourceTree have to do: as shows the preview panel on the bottom of the window, seems that leaving it unchecked SourceTree will do a merge with --no-ff flag, but this doesn't happen.

SourceTree always does what git does naturally: a fast forward merge if there aren't commit in develop branch from the creation of the branch, a no fast forward merge in the other case.

I've tried also to activate the option "do no fast forward when merging, always create commit" under "git option", but also in this case seems that nothing changes: every time, if there aren't commit between branch creation and branch merging, SourceTree does a fast forward merge.

So, there is a way to solve this? I'd like to implement exactly git-flow workflow...


3 answers

1 accepted

0 votes
Answer accepted

This is actually what standard git-flow does - if there are no commits on the develop branch since the feature was started, it does not use the --no-ff option. SourceTree is just calling the git-flow script and this has been its behaviour for a long time.

A few people have expressed that they don't like this, and I think at least one person has forked git-flow to change this behaviour, so far we've stuck to the stock version. This is the code in the git-flow scripts that makes the choice:

if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
		git merge --ff "$BRANCH"
		git merge --no-ff "$BRANCH"

The problem with this standard Git-flow behavior is that the Feature-branch name in the merge message is lost. With 2+ commits in a feature branch the merge message would look like "Merge branch 'feature/CRE-128' into develop". Opposed to that, a single commit feature-branch, which is merged with fast-forward only contains the commit message, which dont has the Feature/JIRA-issue attached to it. Any plans on customizing this behavior? Or the best workaround? Is it save to alter the git-flow scripts or are they overwritten with the next update?

Like # people like this

Ok, for everyone encountering the same issue like the Lorenzo (as myself). SourceTree (win) uses the original GitFlow script, but extract them to folder "%UserHome%\AppData\Local\Atlassian\SourceTree\gitflow_local\gitflow\". So, to always merge with no-fast-forward (especially for single-commit-features), in file "git-flow-feature", replace the following...

# merge into BASE
	git checkout "$DEVELOP_BRANCH"
	if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
		git merge --ff "$BRANCH"
		git merge --no-ff "$BRANCH"

with this...

# merge into BASE
	git checkout "$DEVELOP_BRANCH"
	git merge --no-ff "$BRANCH"


which I think is the expected and cleaner behavior. Would be really grateful if this would be added to SourceTree.

So git flow never do a --no-ff merge if into the feature branch there is only a commit? I've well understand the code?


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in DevOps

Step up your DevOps game webinar Q&A series - Questions answered!

  On October 21st, 2020 we hosted a webinar titled,   Step Up You DevOps Game with 4 Key Integrations for Jira and Bitbucket. We had a great showing and high engagement, but that meant th...

106 views 0 1
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you