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

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.


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.


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.