Published at
Updated at
Reading time

This post is part of my Today I learned series in which I share all my learnings regarding web development.

Today, in one of our Slack channels at Contentful, I saw our infrastructure developers' talking about the git subscribe command. They shared how they use the command to access release information. I didn't know about git describe and dug deeper.

The official git describe documentation describes the command's functionality as follows:

The command finds the most recent tag that is reachable from a commit.

I opened my terminal and started playing around with the command in one of my projects.

# find recent tag from HEAD
$ git describe

In this particular repository, the last made commit was a tagged release (v1.0.0-zeta). By default, describe looks into the past from the repository's HEAD. If your HEAD is on a tagged commit, like mine in this case, it shows the last tag without any additional meta information. This example is not helpful. 🙈

I moved on, and I checked out a previous commit to find out more. After running git describe again, it logged a different result to the terminal.

# find recent tag from HEAD 
# after checking out a commit that's not a tag
$ git describe

The command output includes three pieces of information. Let's have a look at how it is encoded!

The starting v1.0.0-epsilon is the next reachable tag. The result also includes the number of commits on top of the found tag and the commit hash of the current commit. The commit hash is prefixed with -g (the g is used to describe that we're dealing with git).

|              ||  |
 \___     ____/  \  \----------- commit hash 
      most         \             of the current commit
     recent        commits
      tag          on top

If you don't want to manually check out a particular commit to find the previous tag from there, you can also pass a commit hash argument to find the next release tag from that moment in time.

# find recent tag from `e85517a284088`
$ git describe e85517a284088

The describe command more configuration to the search for tags more granular. You should have a look if you're looking for tagged commits constantly.

And that's it for today, thank you for reading! ;)

Additional learning – how to access all commits between two commits

Section titled Additional learning – how to access all commits between two commits

Reading the documentation, I also found out that you can get all the commits between two other commits by doing git log hash1..hash2. Another thing I didn't know! 🎉

$ git log 3bc8cdf..8973bae

commit 8973bae7ec443f0a683ddd239cf3a8e9015877cb
Author: Stefan Judis <>
Date:   Thu Aug 18 00:47:43 2016 +0200

    keep session history clean by space prefix - fix #68 (#73)

commit fc7ac34f9c59343c58e6a954e0add30bff6a3d8a
Author: Greenkeeper <>
Date:   Thu Aug 18 00:24:23 2016 +0200

    chore(package): update dependencies (#61)

commit fad11bd51d0c13dd7ca09084ddfe9b55fe8a90f1
Author: Stefan Judis <>
Date:   Thu Aug 18 00:14:37 2016 +0200

    only build on node v6 - fix #71 (#72)

Related Topics

Related Articles