Last Updated: November 19, 2020
·
73.95K
· jerel

Generate your changelogs with Git log

Nobody likes writing out a changelog by hand so how about making life a little easier? Using the same convention as Github does with linking to issues you can easily generate the html for a changelog.

When you create a commit that should be listed in the changelog just place #changelog in the commit message (probably on the second line so it doesn't show). Now when you release all you have to do is run this one liner:

git log v2.1.0...v2.1.1 --pretty=format:'<li> <a href="http://github.com/jerel/<project>/commit/%H">view commit &bull;</a> %s</li> ' --reverse | grep "#changelog"

Picture

I wrote about this a year or so ago where I specified how to do it omitting only the Merge commits. That's handy if team members don't want to hashtag their messages but you still want to base your changelog on your git log: http://unruhdesigns.com/blog/2011/07/generating-a-project-changelog-using-git-log

Related protips:

git checkout remote branch

3 Responses
Add your response

I remember reading your post about it and i actually use an alias to generate my markdown version of my changelog

chlogm =  !sh -c 'git log $1...$2  --pretty=format:\"%s [view commit](http://github.com/$3/$4/commit/%H) \"' -

and use it like this:

git chlogm first_tag last_tag github_user github_repo

ex:

git chlogm v1 v2 bainternet Admin-Page-Class
over 1 year ago ·

You could use git notes rather than hashtags.

I guess if a log contained characters such as < > or & that need escaping, this would be a manual edit afterwards. Is that right?

over 1 year ago ·

Try Automatically generate change log from your tags, issues, labels and pull requests with Github-Changelog-Generator!
Automatically generate change log from your tags, issues, labels and pull requests on GitHub.

over 1 year ago ·