I decided to write about how I handle production changelogs with Git using tags. After bunch of commits to my dev
branch and when everything has been tested thouroughly, I merge it to master
branch.
When I’m satisfied with the results, I tag
the latest commit (HEAD
) using the following command:
git tag 1.1
When I have at least two tags, I export the changelog by doing the following:
git log 1.0..1.1 --no-merges --pretty=%s > Changelogs/v1.1.txt
Here is an example scenario:
The following example doesn’t use TDD methodology, so bear with me!
- Commit 1 to
dev
branch - Commit 2 to
dev
branch - Commit 3 to
dev
branch
TESTING TIME!
- Merge
dev
branch intomaster
- Tag
master
branch as 1.0 - Deploy!
PROGRAMMING TIME!
- Commit 4 to
dev
branch - Commit 5 to
dev
branch - Commit 6 to
dev
branch
TESTING TIME!
- Merge
dev
branch intomaster
- Tag
master
branch as 1.1 - Deploy!
- Export changelog:
git log 1.0..1.1 --no-merges --pretty=%s > Changelogs/v1.1.txt
Done! Now you have changelogs with all commits (without merges) in a clean format. If you want an unordered list items, you can do:
git log 1.0..1.1 --no-merges --pretty=<li>%s</li> > Changelogs/v1.1.txt
Then you just copy the li
‘s to a HTML document of your choice.
Hope this helps.