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

git flow merge --no-ff

Lorenzo Bugiani August 19, 2013

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...

Thanks!

3 answers

1 accepted

0 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2013

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"
	else
		git merge --no-ff "$BRANCH"
	fi

krabat July 23, 2015

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
1 vote
krabat July 24, 2015

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"
	else
		git merge --no-ff "$BRANCH"
	fi

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.

0 votes
Lorenzo Bugiani September 24, 2013

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?

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events