Created
July 5, 2012 20:45
-
-
Save developernotes/3056312 to your computer and use it in GitHub Desktop.
Display a simple changelog between the last two tags in a Git repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env sh | |
firstTag=$(git tag | sort -r | head -1) | |
secondTag=$(git tag | sort -r | head -2 | awk '{split($0, tags, "\n")} END {print tags[1]}') | |
echo "Changes between ${secondTag} and ${firstTag}\n" | |
git log --pretty=format:' * %s' ${secondTag}..${firstTag} |
Tags sorted by date:
firstTag=$(git tag --sort=-committerdate | head -1)
secondTag=$(git tag --sort=-committerdate | head -2 | tail -1)
Faster (only 1 git command) sorted by date:
latestTags=($(git for-each-ref refs/tags/* --sort=-taggerdate --count=2 --format="%(refname:short)"))
firstTagHF=${latestTags[0]}
secondTagHF=${latestTags[1]}
You can also filter by name if you want:
git for-each-ref refs/tags/<tag_name_start>*
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
secondTag=$(git tag | sort -r | head -2 | tail -1)