Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I use tags vs. release/beta branches for versioning?

People also ask

What is the diff between feature branching and tagging?

Both branches and tags are essentially pointers to commits. The big difference is that the commit a branch points to changes as you add new commits, and a tag is frozen to a particular commit to mark a point in time as having a certain significance.

What is the point of a release branch?

The release branch helps isolate the development of an upcoming version and the current release. The release branch's lifetime ends when a particular version of a project is released. Once this branch merges into the develop and main branches, it can be deleted.

What is the difference between branch and tag in Git?

The difference between tags and branches are that a branch always points to the top of a development line and will change when a new commit is pushed whereas a tag will not change. Thus tags are more useful to "tag" a specific version and the tag will then always stay on that version and usually not be changed.

What is the difference between release and tag in GitHub?

Releases are based on Git tags, which mark a specific point in your repository's history. A tag date may be different than a release date since they can be created at different times. For more information about viewing your existing tags, see "Viewing your repository's releases and tags."


A tag is immutable.

Whereas you can create a branch named "1.0.0" - you, or anyone with commit rights, can also then simply push to that branch (deliberately or not) and change what 1.0.0 means.

You can't do that with a tag, once you create a tag - that's it; Tag 1.0.0 means exactly that and can't be changed*.

That's the main practical difference between a tag and a branch

*You can delete and recreate a tag thereby changing a tag, but certainly not by accident.


Tags are mainly used for future reference to the specific version of the project, by tagging a commit. You can always use branches of course, but if you change versions a lot, you will end up with lots of unused or rarely used branches.

Practically, tags are branches without branches anyway, just adding a way to reference a specific version of the project to reduce complexity.

Edit: Here is a nice way to use git that I use for all my projects.


Branch and tag are the same thing (pointer to a commit, aka. "ref"), except branch automatically moves to the next commit while tag stays forever1 on the same commit.

When making a release, you generally want to mark the "snapshot" of the code from which that release was built, and you want it to stay marked that way even as you continue to evolve the code, so you'd use a tag.

If you tried using a branch for that, it could inadvertently move to a different commit, from which the release was not built.


1 Unless you delete the tag, of course.

NOTE: I realize this is an old question, but I felt that the similarity (and one crucial difference) between branches and tags has not been fleshed out in other answers as clearly as it could have been.


I tend to use a workflow that incorporates both tags and branches. Tags are good for marking released code or notable development builds. Branches are good for keeping track of all changes relevant to a specific version.

Here's a good writeup on this type of workflow: http://nvie.com/posts/a-successful-git-branching-model/