For the last months, I am making use of git tagging a lot, usually creating a tag and pushing it to the repo and rarely deleting it. This is a quick and dirty article stating my most used tagging commands for further reference.
In this quick article we'll see:
Just keep in mind that for this article I understand that you are familiar with
git and what is it for, as I'm going to jump directly to one of its functionalities. To know more about git you can read this article in the official documentation: Getting Started - What is git?
Git Tagging is the ability of marking a specific point in the respository's history, as stated in the official documentation. To make it more understandable, we want to mark a point in the list of commits of the codebase for a further use, for example as a version. We want to say "at this point of time, everything works well together, so I mark it as the version 123"
Tags are useful as one can relate to them externally. For example having a python library in a repository, we can relate to a point in time as a version, and use that version to ensure that it works good with our code.
See this line in a
requirements.txt file of a program in python:
The program will use the code in the git repository
https://github.com/XaviArnaus/pyxavi that is tagged with the version
0.1.2. I can still keep on working in the library, adding more features and even remove stuff, and tagging all of these with new versions, but as long as the program relate to that
0.1.2, the git repository will return the code state by then. Very useful.
One more time: this is my cheatsheet for git tagging. For a more elaborated and full reference for git tag please head to the official documentation.
Make sure that all references to the version are up-to-date (docs, READMEs,
This creates a tag in local.
$ git tag -a v0.1.2 -m "v0.1.2"
-m). Can be a longer string, I don't use it.
This pushes a defined local tag to the remote repository
$ git push origin v0.1.2
Once the tag is pushed, you need to delete it from remote AND from local. It is done separately. I personally do first the remote one and then the local one.
This only affects the remote repository, not the local
$ git push --delete origin v0.1.2
This only affects the local code, not the remote repository
$ git tag --delete v0.1.2