Commit messagesΒΆ
The purpose of a commit message is to tell which change has been done. This is important to be later able to find the version to which to return if something goes wrong. Sometimes you may have to browse commit history after a rather long time.
Commit message should be long enough to describe the change clearly, but at the same time it should as short and concise as possible. One commit should have only a single change. In this way, it is easier to keep the length of the message short. If there is need for a longer explanation, the commit message can be divided into a title and a body. Now the body can explain why the change has been done.
In the commit message, you need not tell the target file of the change, since Git shows the messages at those files that have been changed. Instead, it is a good idea to tell e.g. the target function of the change.
Commit messages should be commands, and thus, you should start the message e.g. with the following words (verbs):
Add
Remove
Update
Fix
Refactor
Examples of whole commit messages:
Add function
XRemove deprecated methods
Update getting started documentation
Fix bug in function
X,
where X is replaced with a real name that appears in the program.
Note from the above examples that a message starts with an upper-case letter, and there is no period at the end of the message.