Feature branch with or without fast-forward merge?

2.9k views Asked by At

I'm using git for a long time now. But I've never used it in a collaborative way. I'm currently setting up a new project and planning a lot of things, among others: how to git?

Okay so I've started reading a bit and it was a simple decision to say: Fine, we'll use a feature branch workflow. That's awesome.

Next question: Merge or PR? Merge! Fine.

Last question: FF or non-FF?
Does it even make sense to merge FF in a feature branch workflow? It just feels like the whole feature branch story is waste when merging FF.
Are there any drawbacks using non-FF that I've not considered?


When reading a "flat" (like git log --oneline) git log I think it's not a big deal having those merge commits. But when using some more fancy git log --format ... it can be totally helpful when a log looks like this. At least in my opinion.

*   e3f667e (HEAD, origin/master, master) Merge branch 'issue#1702'
|\
| * ec359fe (origin/issue#1702, issue#1702) 1702: two
| * 45a63b3 1702: two
* |   97bbec7 Merge branch 'issue#1701'
|\ \
| |/
|/|
| * f959cc9 (origin/issue#1701, issue#1701) 1701: two
| * 9217d3c 1701: one
|/
*   6c934ea Merge branch 'issue#1606'
|\
| * 365eac5 (origin/issue#1606, issue#1606) 1606: two
| * 95df1c9 1606: two
| * ad79b01 1606: one
|/
*   02dbcea Merge pull request #1 from babbelnedd/issue#1605
|\
| * d24d200 (origin/issue#1605, issue#1605) 1605: two
| * 7ef0a8e 1605: two
| * 5aac64d 1605: one
|/
* 585d8b9 Initial commit
2

There are 2 answers

0
Nick Volynkin On

Looks like Gitflow headliners meant to use fast-forward merge.

Citation from Jeff Kreeftmeijer's blog about the Git-Flow tool. Note the "fast-forward" message.

As the output already explains, you're now on a new branch you can use to work on your feature. Use git like you normally would, and finish the feature using feature finish when it's done:

$ git flow feature finish authentication
Switched to branch 'develop'
Updating 9060376..00bafe4
Fast-forward
 authentication.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 authentication.txt
Deleted branch feature/authentication (was 00bafe4).

Summary of actions:
- The feature branch 'feature/authentication' was merged into 'develop'
- Feature branch 'feature/authentication' has been removed
- You are now on branch 'develop'
0
David Deutsch On

You are absolutely correct that it makes no sense to use feature branches while at the same time doing FF merges.

The "Gitflow way" is to not use FF when merging in topic branches:

The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.

(Source)