Reading the gitflow model, it seems to me that the master branch is there only to provide a branch where to store stable versions. What does that add to just tagging develop
with the stable versions?
2 Answers
It is similar to the question "Why do we say 'today', instead of 'the day that started the last time the clock went from 23:59 to 00:00'?"
Having the concept of "latest stable" codified in a branch rather than something you have to search for simplifies things.
Whenever you need the latest stable version of the code, you check out the master branch. If you only use tags to mark stable versions, you'd need to first find out what the latest version was so you can check out the correct tag.
You can also feed it into your production line; any time a commit is made to the master branch, that triggers a build and deployment of your product.
You could do all those things without a master-branch; without any branches or tags at all. But it is easier with them, and the whole point of git-flow is to make things easier. Easier to know what you should do, what others do and to communicate about those doings.
Not quite/completely. But you’re not far off.
Sure, it does give a stable name to the tip of the state of production. But the “release” process is so incredibly rigid that you hardly gain any information from the branch itself:
- Every commit to
master
is a true merge from some other branch - Every commit to
master
is tagged - Every commit to
master
is a new production release by definition (italics in original)
master
has become so bubble-wrapped that you can clearly make out what
master
is even if it was to turn invisible.
So what do you gain? You get an effective alias for the latest release
tag. Okay. Is that hard to remember, or to look up? Since all commits to
master
are true merges (--no-ff
) you also get to navigate back to
previous versions from each commit on master
by following the first
parent. (What for?) Another thing you gain is that you can easily see
what the previous versions were named. But your versions were probably
some appropriately boring monotonically increasing things, so I don’t
see what you will learn from that.
You also gain this:
Therefore, each time when changes are merged back into
master
, this is a new production release by definition. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers everytime there was a commit onmaster
.
For the price of all that ceremony, you gain the ability to indirectly push a “deploy” button by committing to a branch instead of pushing the “deploy” button directly.
develop
: hotfixes. Hmm, still curious about other pitfalls.gitflow
also assumes there is an integration phase in therelease-*
branches, and that work might evolve for some until it becomes a stable release while thedevelop
branch has progress further in the mean time. Simple tagging wouldn’t allow you to capture that.release-*
branch (which are not meant to be long lived branches) to accurately point to the actually release code, and not in thedevelop
branch because you might have added new commits todevelop
in the meantime. The image in the link is a bit erroneous because it doesn't illustrate that, while you're doing the release, other devs might be committing todevelop
.