Skip to content

Git Commit Guidelines

Islam El-Nabarawy edited this page Aug 25, 2015 · 1 revision

Git Commit Guidelines

Git is a very powerful source control tool that, when used correctly, can create a very easy to access and use coding environment. These guidelines are meant to help us standardize our commit messages which will make maintaining code and understanding changes easier.

A commit should be a small change to the repository which focuses on a single functionality. Commits should be kept small and focused to make reviewing easier and to make any maintenance simple and straightforward. If you have changed multiple aspects of the code "git commit -p" will allow you to pick which changes should be committed.

Before committing a change it is important that you test this change extensively. Since you are not the only person working on the code it is important that the code in the remote repository stays usable and up to date. Please ensure that your local repository is up to date with the remote repository before doing a push (git pull).

A commit message will consist of two main parts: the title and the body. The title of a commit message should be descriptive and should give a brief description of what the change accomplishes. The title should be no longer than 50 characters and should be written in the imperative (Change, add, etc.). This part of the message is considered to be the title and should not end with a period.

The commit body should be a much more detailed description of a change. This will describe in detail what the change is and how it will affect the current repository. This summary can be multiple paragraphs and can use bullets in the form of a "-" or "*" if it helps. Each line of the body should be wrapped at 72 characters.

An example commit might look like this:

Give example commit message (50 characters)

This is the detailed description of what this commit is to accomplish.
It should be as long as necessary to get your point accross.  Each line
should be wrapped at 72 characters.  It is also important to include a
blank line after the title.

It is okay to use multitple paragraphs and any formatting that may make
the message easier to read such as bullets.