Good ways to manage a changelog using git?

2019-01-15 23:26发布

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!

12条回答
Melony?
2楼-- · 2019-01-16 00:11

I also made a library for this. It is fully configurable with a Mustache template. That can:

I also made:

More details on Github: https://github.com/tomasbjerre/git-changelog-lib

enter image description here

查看更多
不美不萌又怎样
3楼-- · 2019-01-16 00:12

For GitHub projects it might be useful: github-changelog-generator

It generates changelog from tags closed issues,and merged pull-requests.

This CHANGELOG.md was generated by this script.

Example:

Changelog

1.2.5 (2015-01-15)

Full Changelog

Implemented enhancements:

  • Use milestone to specify in which version bug was fixed #22

Fixed bugs:

  • Error when trying to generate log for repo without tags #32

Merged pull requests:

  • PrettyPrint class is included using lowercase 'pp' #43 (schwing)

  • support enterprise github via command line options #42 (glenlovett)

查看更多
We Are One
4楼-- · 2019-01-16 00:16
git log --oneline --no-merges `git describe --abbrev=0 --tags`..HEAD | cut -c 9- | sort

Is what I like to use. It gets all commits since the last tag. cut gets rid of the commit hash. If you use ticket numbers at the beginning of your commit messages, they are grouped with sort. Sorting also helps if you prefix certain commits with fix, typo, etc.

查看更多
Viruses.
5楼-- · 2019-01-16 00:16

I let the CI server pipe the following into a file named CHANGELOG for a each new release with the date set in the release-filename:

>git log --graph --all --date=relative --pretty=format:"%x09 %ad %d %s (%aN)"
查看更多
Animai°情兽
6楼-- · 2019-01-16 00:20

Based on bithavoc, it lists the last tag until HEAD. But I hope to list the logs between 2 tags.

// 2 or 3 dots between `YOUR_LAST_VERSION_TAG` and `HEAD`
git log YOUR_LAST_VERSION_TAG..HEAD --no-merges --format=%B

List logs between 2 tags.

// 2 or 3 dots between 2 tags
git log FROM_TAG...TO_TAG

For example, it will list logs from v1.0.0 to v1.0.1.

git log v1.0.0...v1.0.1 --oneline --decorate

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-01-16 00:28

A more to the point CHANGELOG. Tell me if you people like it.

git log --since=1/11/2011 --until=28/11/2011 --no-merges --format=%B
查看更多
登录 后发表回答