Deploying an app to production typically happens using some tool like Jenkins. The deployment job usually takes the Git tag as input parameter. The parameter is used to checkout the expected version of the app, build & deploy it.

Now, the tag to be used must obviously be assigned in advance. The developers probably follow a specific development/release procedure (Git Flow anyone?) and tag releases when they are “done”.

I sometimes want to deploy a version of the software which is not ready yet. A typical scenario is that I cannot reproduce a bug in my local development environment but can see it in production or staging. In this case, I’d like to deploy (to staging!) a version of the app with some debugging statements included.

The deployment tool wants a tag for deployment though. I surely just need to tag this debug version and deploy it! I tend to forget how to do this and I also want the process to be as smooth as possible.

Here’s what I defined in my shell:

function tag_debug_version () {
    # Tag the current HEAD and publish it.
    TAG=test_tag_rolf
    git tag -d $TAG # delete previous tag
    git tag $TAG # make a new tag on HEAD
    git fetch --tags origin # update other people's tags
    git push -f origin $TAG # publish
}

Plain and stupid but it does the job. So the workflow for the described scenario is:

$ git checkout -b tmp-debug master # create the debug branch

# add some tracing and commit
$ git commit -m "Add debug output"

$ tag_debug_version # tag & push the debug version

# deploy version "test_tag_rolf"

Using the same tag has the advantage of not polluting the repo with pretty useless debug versions. Furthermore, the browser’s form cache will remember it so you don’t have to type it out again during deployment (assuming deployment happens via a web interface).