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

Feature branch with one commit

s_shatzkiy August 13, 2013

Hi!

I'm new to git and SourceTree. We plan to use git in our new project with git flow. I tested features of SourceTree and have one question.

When I start a new feature, make one commit and finish the feature - history looks linear - as if I simply committed to the develop branch. But when I start a feature, make two or more commits and finish it - then the history shows branches from develop.

Is it behavior correct or did I miss something? I tried the same thing with another git tool and got expected results. I prefer SourceTree however and want to solve this issue.

3 answers

1 accepted

0 votes
Answer accepted
s_shatzkiy August 19, 2013
I found explanation of described behavior in git flow sources (https://github.com/nvie/gitflow/blob/develop/git-flow-feature).
# merge into BASE
	git_do checkout "$DEVELOP_BRANCH"
	if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
		git_do merge --ff "$BRANCH"
	else
		if noflag squash; then
		    git_do merge --no-ff "$BRANCH"
		else
			git_do merge --squash "$BRANCH"
			git_do commit
			git_do merge "$BRANCH"
		fi
	fi
 
But I have no idea why there is this "if" with fast-forward and without fast-forward.
s_shatzkiy August 19, 2013

Relevant issue on git flow - https://github.com/nvie/gitflow/issues/292

2 votes
Ilya Shaisultanov August 19, 2013

There's an open issue regarding this - https://github.com/nvie/gitflow/issues/292. Seems that it was author's decision, with no explanation given.

0 votes
KieranA
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.
August 13, 2013

Hi Sergey,

This sounds like a simple case of a fast forward commit which means your commit is directly upstream of the branch. The git-scm docs explain it well:

You’ll notice the phrase "Fast forward" in that merge. Because the commit pointed to by the branch you merged in was directly upstream of the commit you’re on, Git moves the pointer forward. To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a "fast forward".

A fast forward commit is the default in SourceTree because in those cases there's usually no need to have a branch history like that, it may as well be linear. You can turn this off though from within SourceTree by turning the checkbox "Create a commit even if merge resolved via fast-forward" from the merge sheet.

Hope that helps

s_shatzkiy August 14, 2013

Yes, I can do it with plain merge (button Merge on toolbar), thank for your advice, and I already try it. It works. But can I reach this goal by git flow feature (button Git Flow on toolbar)? Or when SourceTree finish gitflow branch it always do fast-forward in merge?

Like # people like this
s_shatzkiy August 19, 2013

Thank you for help, I post my own answer to my question. Can you provide may be any comments to this answer?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events