How to use tags in Git

A tag in Git is a user-friendly label attached to a particular commit. It is commonly used to mark a particular commit, for example to mark as a release version. Using tags in Git is quite easy, once you notice how they are pushed to a remote repository.

  • To list tags in your repository:
$ git tag
  • To checkout a tag, it has to be checked out to a new local branch:
$ git checkout -b FOOBAR_BRANCH FOOBAR_TAG
  • To mark the current commit with a tag named FOOBAR_TAG:
$ git tag FOOBAR_TAG
  • If you know the hash of a particular commit, say abcd1234, and want to attach a tag to it:
$ git tag FOOBAR_TAG abcd1234
  • If you want to label the head commit of a branch with a tag:
$ git tag FOOBAR_TAG XYZ_BRANCH
  • There are times when you want to do a reverse lookup, to lookup the commit associated with a tag. There are a couple of ways to do this:
$ git log -n 1 FOOBAR_TAG
$ git rev-list -n 1 FOOBAR_TAG
  • When you push your new commits to a remote, the tags you created locally are not pushed. This command pushes only the tags (not any new commits) to a remote:
$ git push FOOBAR_REMOTE --tags
  • There are times when you want to move a tag to a different commit. This operation essentially removes the old tag and writes a tag with the same name at the new commit. This can be done if you create the new tag (with the same name) with force:
$ git tag -f FOOBAR_TAG
  • If you try to push a moved tag (like the above example) to a remote, Git will complain that the remote already has a tag of the same name pointing at a different commit. Again, you use force to coerce Git to do this:
$ git push -f FOOBAR_REMOTE --tags

Tried with: Git 2.7.4 and Ubuntu 16.04

How to view specific revisions in Mercurial log

I typically check the Mercurial history of a repository using the log or the graphical log -G method. I sometimes find it convenient to view only the tags or heads in the same log format. This is as if the log was filtered out to show only the tags or heads log entries.

This can be done by passing the resulting list of revisions from the tag or head functions to the log option:

$ hg log -r "tag()"
$ hg log -G -r "tag()"
$ hg log -r "head()"
$ hg log -G -r "head()"

Tried with: Mercurial 2.8.2 and Ubuntu 14.04

PuddleTag

MP3Tag is a popular and useful MP3 tag editor on Windows. I was looking for an alternative to MP3Tag on Ubuntu and discovered PuddleTag.

PuddleTag tries to be a drop-in replacement for MP3Tag and it gets the job done. It can be used to edit tags and filenames of MP3 and FLAC files.

Installing PuddleTag is easy:

$ sudo apt-get install puddletag

Tried with: PuddleTag 0.10.6.3 and Ubuntu 12.04 LTS

StackOverflow: Follow tags in realtime with StackGuru

If you want to be updated on all new questions of a certain tag on StackOverflow, using the browser to manually check for new questions is painful. StackOverflow does allow users to get email notifications on updates once every 15 minutes. It also supports RSS notifications on tags. But sometimes, you want something more real-time than email or RSS.

What you need is a program that will monitor the tags you are interested in and notify you as soon as a question on the tag appears. StackGuru is a Jabber bot that can do this work for you.

Using StackGuru is pretty simple:

1. Install a Jabber client on your computer. I personally like the minimalism of Psi and use it for this purpose. Or you can use the GChat interface in Gmail also.

2. Open your Jabber client and login using any Jabber ID. You can use your Gmail login as a Jabber ID. Or create a Jabber ID on many Jabber servers on the Internet.

3. Add stackguru@appspot.com as your friend.

4. To follow questions of a tag, say java, send this message to stackguru@appspot.com: follow java

5. To unfollow questions of a tag, say java, send this message to stackguru@appspot.com: unfollow java

6. To view the tags you are currently following, send this message to stackguru@appspot.com: follow

7. stackguru@appspot.com will message you whenever a question on any of the tags you are following is posted on StackOverflow

For more commands that StackGuru can handle, see here.

Tried with: Psi 0.14

StackOverflow: Email Notifications on Questions from a Tag

When learning a new language or concept in programming, it might be useful to follow all the new questions that are posted on StackOverflow related to that concept. All questions on StackOverflow are nicely tagged, so the concept you want to follow can be tracked easily. One way to track all new questions on a certain tag is to get email notifications when that happens.

To be able to do this, visit the StackOverflow tags page. Find the tag you want and hover your mouse pointer over the tag. A overlay window pops up. Choose Subscribe here to get email notifications.

The email notifications are handled from a central StackExchange service. The email notification frequency is once per day by default. This can be changed to either once every 3 hours or every 15 minutes.