Skip to content

Git Tags

Git Tags are great for tracking meaningful versions of your code

They are an essentail part of any library used by a package manager such as Composer

Configure git push to push tags at the same time

To configure git push to also push tags, you need to edit the .git/config file in your project repo and ensure that the remotes you want to push tags for look like:

[remote "origin"]
    url = git@server:path/to/repo.git
    fetch = refs/heads/*:refs/remotes/origin/*
    push = refs/heads/*
    push = refs/tags/*

Easily Handle Semver Tags

Keeping track of semver tags can be a bit painstaking. To make life easier suggest you do this:

mkdir ~/bin
cd ~/bin
wget https://raw.githubusercontent.com/tomologic/bump-semver/master/bump.sh
mv bump.sh bump
chmod u+x bump

And then in any project using semver tags, you can bump the tag with the bump command, eg

$ bump patch
tagging 1.1.1 3860ff9c56dcc2a174c54771f33bbfec2dd2857b

Tag Prefixes

If you are working with repos with tag prefixes, eg v, then you need to define a PREFIX variable, or you can just edit the bump script

For example edit bump so it looks like:

#!/bin/bash
# Bumps the semantic version of the git-project.
# If no semantic version tags exist in the project, the version starts out at v0.0.0
# and is incremented by one for the field indicated by the bump command argument.

#Set prefix <--- THIS BIT
PREFIX='v'

find_latest_semver() {
  pattern="^$PREFIX([0-9]+\.[0-9]+\.[0-9]+)\$"
...