Fork me on GitHub

Semantic branching model

Version: 1.0.0-alpha-1

Branching model

License

Made available under the Creative Commons Attribution-ShareAlike license.

Authors

Assumptions for a project using the semantic branching model

Goals

Why not just using “A successful Git branching model”?

Branch semantics

  1. master collects changes towards the next major release.
  2. release/X.Y branches collect changes towards the next minor release.
  3. release/X.Y.Z branches collect changes towards the next patch release.
  4. New features are directed either towards master or towards release/X.Y branches.
  5. Patch release branches release/X.Y.Z never receive new features, they only receive bugfixes.

Lifetime of branches

Release preparation

The release process consists of the following steps: feature freeze, converging a release candidate, and tagging a release.

Feature freeze and branch creation

Feature freeze is the moment when a new release branch is created, either release/X.Y is created from master, or release/X.Y.Z is created from release/X.Y. The creation of a release branch may be delayed up to the moment until the root branch receives changesets towards the next major or minor release.

Converging a release candidate

Often some work needs to be done between a feature freeze and arriving at the release commit: this work typically consists of bugfixes, cosmetics, documentation, together with testing.

Tagging a release

Tagging a specific commit with a release version creates the actual release. We recommend to use annotated tags because they contain the author of the tag.

Bugfixes

Source branch

When creating a new branch for a PR, it should always start off from the branch to which the change is directed. The naming of the new branch should follow standard feature/issue branch naming conventions, i.e. the feature branch in the fork should not be named identical to the target branch in the upstream repository (see Do Not Issue Pull Requests From Your Master Branch).

Explanation:

Example:

Target branch

Frequently-asked questions

Do I need release branches at all? Can’t we just tag releases on master?

If you never want to release patches to released versions, tagging versions on master is probably sufficient. The moment your project receives patches to released versions, you need to create branches.

My project does not use semantic versioning, does this model still make sense?

This model probably still makes sense but you probably do not need two levels of release branches but probably require only one, supporting each release.

My project does not use fork-and-pull-request workflow, does this model still make sense?

You can employ this model also within a single repository. For this write-protect master and release branches and employ code review before accepting merges from feature or bugfix branches towards either master or release branches.

Will my project not end up with many branches?

Possibly - but branches are cheap. If you do not like to have a branch for each single release, you can delay the creation of a corresponding release branch until the moment when a past release is about to receive a patch which you would like to isolate from other changes which have the past release as parent.