I've been using Git for a while now, and I recently started using it to tag my releases so that I could more easily keep track of changes and be able to see which version each of our clients are running (unfortunately the code currently mandates that each client have their own copy of the PHP site; I'm changing this, but it's slow-going).
In any case, we're starting to build some momentum, I thought it would be really good to be able to show people what has changed since the last release. Problem is, I haven't been maintaining a changelog because I don't have a good idea of how to go about it. For this particular time, I can run through the log and manually create one, but that will get tiring very quickly.
I tried googling "git changelog" and "git manage changelog" but I didn't find anything that really talked about the workflow of code changes and how that coincides with the changelog. We're currently following Rein Henrichs' development workflow and I would love something that went along with that.
Is there a standard approach that I am missing, or is this an area where everybody does their own thing?
Thanks very much for your comments/answers!
For a GNU style changelog, I've cooked the function
With this:
gnuc
and now my clipboard contains something like:
Then I use the clipboard as a starting point to update the ChangeLog.
It is not perfect (e.g. files should be relative to their ChangeLog path, so
python/py-symtab.c
withoutgdb/
since I will edit thegdb/ChangeLog
), but is a good starting point.More advanced scripts:
I have to agree with Tromey though: duplicating git commit data in the ChangeLog is useless.
If you are going to make a changelog, make it a good summary of what is going on, possibly as specified at http://keepachangelog.com/
You can use some flavor of git log to help you out:
If you name your branches nicely, so that a merge to master shows up as something like "Merged branch feature-foobar", you can shorten things by only showing that message, and not all the little commits that you merged, which together form the feature:
You might be able to augment this with a script of your own, which could do things like strip out the "Merged branch" bits, normalize formatting, etc. At some point you have to write it yourself though, of course.
Then you could create a new section for the changelog once per version:
and commit that in your version release commit.
If your problem is that those commit subjects aren't anything like what you'd want to put in a changelog, you pretty much have two options: keep doing everything manually (and try to keep up with it more regularly instead of playing catch-up at release time), or fix up your commit message style. One option, if the subjects aren't going to do it for you, would be to place lines like "change: added feature foobar" in the bodies of your commit messages, so that later you could do something like
git log --pretty=%B | grep ^change:
to grab only those super-important bits of the messages.I'm not entirely sure how much more than that git could really help you create your changelogs. Maybe I've misinterpreted what you mean by "manage"?
Since creating a tag per version is the best practice, you may want to partition your changelog per version. In that case, this command could help you:
This was about 3-4 years ago, but for the sake of future searchers, it's now possible to generate gorgeous logs with:
Or, if you want it even prettier (with color for terminal):
Piping that output to ChangeLog is what I currently use in all my projects, it's simply amazing.
The
gitlog-to-changelog
script comes in handy to generate a GNU-styleChangeLog
.As shown by
gitlog-to-changelog --help
, you may select the commits used to generate aChangeLog
file using either the option--since
:or by passing additional arguments after
--
, which will be passed togit-log
(called internally bygitlog-to-changelog
):For instance, I am using the following rule in the top-level
Makefile.am
of one of my projects:This rule is used at release time to update
ChangeLog
with the latest not-yet-recorded commit messages. The file.last-cl-gen
contains the SHA1 identifier of the latest commit recorded inChangeLog
and is stored in the Git repository.ChangeLog
is also recorded in the repository, so that it can be edited (e.g. to correct typos) without altering the commit messages.DISCLAIMER: I'm the author of gitchangelog of which I'll be speaking in the following.
TL;DR: You might want to check gitchangelog's own changelog or the ascii output that generated the previous.
If you want to generate a changelog from your git history, you'll probably have to consider:
Optionaly you might want some categorization (new things, changes, bugfixes)...
With all this in mind, I created and use gitchangelog. It's meant to leverage a git commit message convention to achieve all of the previous goals.
Having a commit message convention is mandatory to create a nice changelog (with or without using
gitchangelog
).commit message convention
The following are suggestions to what might be useful to think about adding in your commit messages.
You might want to separate roughly your commits into big sections:
Additionally, you could want to tag some commits:
Try to write your commit message by targeting users (functionality) as often as you can.
example
This is standard
git log --oneline
to show how these information could be stored::So if you've noticed, the format I chose is:
To see an actual output result, you could look at the end of the PyPI page of gitchangelog
To see a full documentation of my commit message convention you can see the reference file gitchangelog.rc.reference
How to generate exquisite changelog from this
Then, it's quite easy to make a complete changelog. You could make your own script quite quickly, or use
gitchangelog
.gitchangelog
will generate a full changelog (with sectioning support asNew
,Fix
...), and is reasonably configurable to your own committing conventions. It supports any type of output thanks to templating throughMustache
,Mako templating
, and has a default legacy engine written in raw python ; all current 3 engines have examples of how to use them and can output changelog's as the one displayed on the PyPI page of gitchangelog.I'm sure you know that there are plenty of other
git log
tochangelog
tools out there also.