Learn Git Tag in 6 Commands

Git Jul 8, 2023

It is inevitable for the fast pace of development to have every commit clean and tidy.

Trying to be perfect is counter productive.
branch ---O---O---O---O-- ...
          |   |   |_ This is working ! --> we need this
          |   |_ Oh some fixes 
          |_complete features TGIF !

The commit we needs is the one that’s working and we don’t want to organize things like crazy.

There must be some easy way to label and also go back to “that” working commit when needed

Git tag will help you out with this

1. Local create

$ git tag -a v0.1 -m 'first working'

This will give you some ability to label the commit.

Note that is doesn’t need to be v0.1 . It can be any text.

2. Local read

$ git tag

3. Local delete

$ git tag -d v0.1

4. Go to that tag

$ git checkout v0.1
$ git checkout v0.2
$ git checkout v0.5

You can go to any tag just like you checkout to any branch or commit_hash

Everything we’ve done so far is on our local machine.

Now we’re going to push the update to the remote server.

5. Remote update

$ git push origin --tags

6. Remote delete

$ git push origin --delete v0.1

Hope this helps.

Cheers!

Tags

TeamCMD

We are CODEMONDAY team and provide a variety of content about Business , technology, and Programming. Let's enjoy it with us.