GIT Commit Good Practice

Commit message

Git commit messages can be considered like a well formed email, it contains a subject line, a body and additional metadata.

topic: Short commit subject

Commit description spanning multiple lines while
staying bound to the 79col limit.

Bug-Id: 1234
CC: libav-stable@libav.org
Sample-Id: 00000000-zzuff
Signed-off-by: Name Surname <email@example.com>

Commit content

A commit should be as atomic as possible, short and impacting the smallest portion of code. Git provides tools such as git bisect that work the best with such small commits and overall reviewing small changes is easier.

Topic

The topic should not the same as the filename, but just hint the area of the code it impacts, e.g.: lavc is a good topic for a patch doing wide changes over libavcodec, build is a good topic for a patch improving the build system.

Additional information

To add additional information such as a commentary or a link to your repository you can use the --annotate option when using git-send-email and write below the --- line.

topic: Short commit subject

Commit description spanning multiple lines while
staying bound to the 79col limit.

Bug-Id: 1234
CC: libav-stable@libav.org
Sample-Id: 00000000-zzuff
Signed-off-by: Name Surname <email@example.com>
---

This is a commentary to the patch, it will not appear in the tree but will help tracking it
if I add a http://link/to/my/repository or if I put my doubt about the patch
here so the reviewer can answer me directly.

 libavcodec/utils.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

In case a broader email should be sent the --compose option can be used to have an initial email before the set of patches.


CategoryHowTo