I am still trying to move from git towards git-flow. I know I can use any kind of git feature within git-flow, but I am mostly interested in what it handles automatically.
Let’s assume there are two developers Alice and Bob, working on feature A and B respectively. When Alice is done, she can do a git flow feature finish A to create a merge commit on her local develop branch based on commit C. Now if Bob finishes his feature at the same time, and he fetched the same stuff, his merge commit will also be based on C. Now if Alice pushes and then bob fetches again, he will have to merge or rebase and we end up with a non-linear history on the develop branch, in case he merges.
Is this correct so far, or does git-flow somehow handle this situation automatically? If there is some automatic mechanism, what will have to be set up for this to work?
The simplest solution would probably be to always fetch develop before finishing features. However I am not sure that this is actually possible, depending on the way the repository is shared (might not be available at that time).
EDIT (clarifications of the problem):
As the answers suggest, my example was not clear. So first a picture of what I think is the problem:
C is the initial commit on the develop branch.
Alice creates some feature work on the feature branch:
develop feature/A
| |
v v
C-A1-A2-A3-A4
At the same time Bob also does work for another feature
C-A1-A2-A3-A4
\
B1-B2-B3-B4
Now Alice finishes the feature and the merge commit is added to develop (I want that).
A1-A2-A3-A4
/ \
C- - - - MA
Now Bob finishes the feature and again a merge commit is added to develop (I also want that, just at another place:
A1-A2-A3-A4
/ \
C- - - - MA <- develop for Alice
\
\ - - - - MB <-develop for Bob
\ /
B1-B2-B3-B4
However now either Alice or Bob has to merge develop, creating an additional commit:
A1-A2-A3-A4
/ \
C- - - - MA-MAB <- I don't want this MAB commit
\ /
\ - - - - MB <-develop for Bob
\ /
B1-B2-B3-B4
What I would like to have instead would be something like this:
A1-A2-A3-A4
/ \
C- - - - MA-MB
\ /
B1-B2-B3-B4- -
As you can see, the history is still non-linear, however the main line of the develop branch only contains the merge commits from features (and no additional merge commits as in the other case).
What I like about this, is that you can easily follow changes in the history and see if they belong to former feature branches or if they were merges in develop. All this information can be derived directly from the DAG.
Also if you use good messages for your merge commits on develop, in the second case you can easily derive a changelog, by always following the first parent on develop. However in the second case you sometimes need to follow the first parent only and sometimes more than one parent. And I cannot see an easy way when to do which that I could code up.
git-flowdoes nothing like that.It’s intended to support the branching model described here (which is really just a pretty picture for the kinds of things Git developers recommend). That picture includes merges. You’ll see the same all through the text. Under each type of branch, you’ll see the types of branches they should be merged into. There are example commands, using
--no-ffto forcibly avoid linear history, and instead record merge commits.This is a workflow that really uses Git, and one of Git’s core strengths is branching and merging. This workflow thrives on merging; nonlinear history is not only unavoidable but desired.
You should read the section titled "Incorporating a finished feature on develop" from the description of the workflow. A short quote:
You want those merge commits. You really do.