Commit messages should say why you made a change, not what you changed.
A good commit message has the following:
- explanation of the problem
- explanation of the solution
- reference to the relevant GitHub issue
The reference to the GitHub issue can be made as a URL or in a short form: #issue
(e.g. #12
). If you refer to an issue from another repo, use org/repo#issue
(e.g. StarcounterAps/Launchpad#12
). GitHub recognizes this pattern and shows a cross-reference.
This is a bad commit message:
bugfix
To write a good commit message that doesn't miss any of the above points you can use the following template. It splits the message into two parts: the problem and the solution. The problem description is in the headline, followed by the explanation why you are making this change. The solution part can be really short because the diff itself is the solution.
Problem: Some elements do not display starting from starcounter-include 3.0.0
This is because they have a slot attribute but there is no respective slot
element in the declarative Shadow DOM (https://github.com/Starcounter/RebelsLounge/issues/152)
Solution: Add missing slot elements to declarative shadow DOM
With such a commit messages, the description of your Pull Request can almost be empty!
If you have not yet pushed your commits, you can still edit the commit messages.
To edit the commit message of the last commit, you can simply change it using git commit --amend
. Sourcetree and other Git GUIs also give an option to amend a previous commit.
To edit commit messages of any commit you can use Git interactive rebase: https://git-scm.com/book/id/v2/Git-Tools-Rewriting-History
Never change commits that have been pushed!
- http://rickardlindberg.me/writing/problem-in-commit-message/
- http://chris.beams.io/posts/git-commit/
- https://github.com/erlang/otp/wiki/Writing-good-commit-messages
- https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message
- http://alistapart.com/article/the-art-of-the-commit
- https://vip.wordpress.com/documentation/commit-messages/
- https://wiki.openstack.org/wiki/GitCommitMessages
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst
- https://github.com/conventional-changelog/conventional-changelog/blob/a5505865ff3dd710cf757f50530e73ef0ca641da/conventions/angular.md