This is a simple and quick way to generate a changelog for your project using your git commit messages.
By default git allows you to format its log messages while it outputs them. By using this feature we can wrap our commit message, create a link to the actual commit, and all sorts of other fun. Then by running it through grep we can filter it further. Here is an example:
git log v2.2.0...v2.2.1 --pretty=format:'<li> <a href="http://github.com/jerel/project/commit/%H">view commit •</a> %s</li> ' --reverse | grep -v Merge
Output (link is 404):
view commit • Fixed a bug in the sympathy sector of the artificial intelligence module.
v2.2.0...v2.2.1tells git log that we only want it to return the commits between those two tags in our project.
--pretty=format:' 'flag we pass the html that we want generated for each commit using the
%splaceholders to output the hash and the message, respectively.
--reverseoutputs the commits in the order they were made instead of the most recent first.
| grep -v Mergewe pipe the output through grep and specify that we don’t want the changelog cluttered up with merge messages (any message with the string “Merge” in it is discarded).
You could even stick this in a post-receive hook to generate a dynamic changelog. Or use grep to only show messages that contain a keyword (like github does with their “Closes issue #501” feature).