Exploit Git Hub tags!

If you put your Perl code on Git Hub, I'd like to encourage you to use a a feature that isn't (at all) intuitive: tags.

Basic tags in git are a human friendly label that point to a certain commit. Basic tags don't have a git object associated with them so they're mostly for use on your local repository.

It is also possible to create "annotated tags" which are first class git objects and point to a specific commit (as the top of a tree of commits.) Because annotated git tags are first class objects, it is possible to share them across repositories. It is these tags that I would encourage you to make if you use Git Hub.

What do you get for your trouble? When you push your tags to Git Hub, it automatically creates a ZIP and tarball download link of that tagged release. That can be handy for a bunch of different reasons - uploading to CPAN or sharing code with people and systems without a git client to name two. (They can also be handy if you don't want to go through BackPAN to find historical releases of modules.)

How do you make (annotated) tags?

git tag -a 'VersionString' <Commit>

Example (where 88df47a represents my HEAD):

git tag -a 'v1.03' 88df47a

Your $EDITOR will fire up and git will prompt you to add a tag commit message. I usually make it the same as the version string on the command line, but it could be whatever makes the most sense to you. And because in some ways git is like perl - there's more than one right way to do this. (This is what works best for me.)

You can tag historical commits too. Just replace the tag string and commit reference at the end of the command line with the appropriate values. You can find historical code commits using git log of course.

To check tags, or explore someone else's tags, you can see all of the tags in a repo by typing:

git tag

Another advantage is that you can substitute a tag pretty much anywhere you need to use a commit reference. Instead of typing 88df47a, I can substitute v1.03 which I think we can agree is a lot easier to remember. (But maybe not - perl hackers' minds work in strange ways sometimes.)

Once you have made the tags you want, you need to push them (just like your regular code commits) using the --tag flag on git push.

Example:

git push origin master --tag

Assuming your origin points to Git Hub, they will take it from there.

P.S. If you're looking for an easy introduction to git covering 80%+ of basic source control workflow, I saw this last night on Hacker News and really liked it. So, have a look.