Git branching strategy I am planning to follow for my open-source libraries #11
thetutlage
started this conversation in
Ideas
Replies: 0 comments
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
The
main
,develop
,production
, andstaging
branching works excellent for applications deployed to a particular environment. Since you always have one copy of the code running somewhere in the cloud.However, the same strategy isn't helpful when publishing open-source (or private) libraries, where each library version is meant to be long-lived on a registry. Depending on your releasing strategies, you might also want to backport bug fixes to published versions.
The first step should be to maintain one branch per major release, as this allows backporting bug fixes to an older version, even if that is meant to be done rarely. We will come back to when these branches should be created.
Getting rid of the main branch
What is the
main
branch anyway?Branch 8.x.x
.Is it the branch containing the changes (including breaking changes) for the future release? If so, shouldn't we just name it after that release version? For example, if the upcoming version is
9.0.0
, then the branch could be9.x.x
.Let's only have version branches
Let's continue with what I have to say, and then we can tell if it makes sense.
1.x.x,
which will also be the default branch.v1
is unstable, all the releases will be made withbeta
tags and appropriate version numbers (i.e.,1.0.0-beta.0
).latest
tag.1.x.x
branch.2.x.x
.2.x.x
branch will be used for future development with features/changes that should not be included inv1
.v1
, then we will merge that change into the2.x.x
branch as well.2.x.x
as the default branch and cut a new release.The mental model here is simple. All work is done against a specific version of the library (that is how it is in reality), and the Git branches should reflect that.
The
main
doesn't mean anything. If you are working on a future release, make a branch for that future major version, but do not make it the default branch yet.Branches will diverge
Since each version is allowed to evolve on its own (especially if you allow backporting bug fixes across major versions), the branches will eventually diverge, and that's okay. That's the reality of libraries—two major versions aren't the same. In fact, in some cases, they might have different project structures, underlying tooling, and so on.
Prior Art
main
branch for active development of future versionsBeta Was this translation helpful? Give feedback.
All reactions