Feature branch with one commit


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
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"
		if noflag squash; then
		    git_do merge --no-ff "$BRANCH"
			git_do merge --squash "$BRANCH"
			git_do commit
			git_do merge "$BRANCH"
But I have no idea why there is this "if" with fast-forward and without fast-forward.

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.

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

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 1 person likes this

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
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,229 views 4 2
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you