over 6 years ago

That's how you get the name of last tag applied to current branch in Git repo:

$ git describe | grep -Eo '^[^-]+'

We need to meddle with grep because git describe gives us additional info
in the form of


Note the funny literal 'g' before the LAST_COMMIT_HASH.

And that's how you get the list of changes since some COMMIT till the current
state of the working copy, in really pretty format "ISO Date (Author) Commit

$ git log --no-merges --pretty=format:'%ai: (%an) %s' COMMIT..HEAD

HEAD is literal "HEAD" there. You can substitute COMMIT token with either
commit hash or tag.

Now you write the following script and place it in the root of the codebase
of your project:


# Get the list of changes made since the last tag

LAST_TAG=`git describe | grep -Eo '^[^-]+'` 
git log --no-merges --pretty=format:'%ai: (%an) %s' $LAST_TAG..HEAD 

Name it as changelog and then you can do just:

$ ./changelog

And get something like this:

2012-09-14 23:50:43 +0400: (E. T.) Some stuff for ticket 1584. re #1584 
2012-09-14 23:45:05 +0400: (A. Y.) Some stuff for ticket 1584. test #1584 
2012-09-14 15:44:49 -0400: (A. Y.) Refactored some old stuff 
2012-09-14 22:24:04 +0300: (D. M.) Improved tests 

And this will be changes only since last tag applied. Excellent for quick reports
about current upstream.

comments powered by Disqus