Instead of writing one-line git commit messages with the commit -m option, in this article learn how to write proper commit messages. A proper commit messages is important, as it allows others to see exactly what you have modified, making your project easier for others to follow helping increase your exposure to the open source community.

Write a Proper Commit Message

Instead of including the commit message in the terminal command, open your favorite text editor to a blank file. The message should conform to the following format:

  • First line is the title, summarizing the entire commit.
  • Following a blank line, the next line or several lines should be any readable description necessary for the commit. This may be as long as desired.
  • All following lines should summarize the exact changes made to the code in such a format:
    • Filename:Line# -- Brief description of modification.

Example Commit Message

Below shows an example commit message:

        
Added Docker support, new is_unique feature, plus bug fix.

Added support for docker-compose and updated installation instruction as necessary. Also included a new feature within check_order() function to check for uniqueness, and fixed small bug when creating product slugs.

src/somedir/library.py:381 -- Added 'is_unique' parameter to the check_order() function.
src/products.py:194 -- Fixed bug when creating product slug.
docker-compose.yml -- Added docker-compose file.
docs/install.md -- Updated installation guide to include how to install via Docker.

Commit Message

When making a commit now, instead of using the -m message, use the --file option. For example, if the filename of your commit message is commit.txt you would run the command:

        git commit --file commit.txt
    

That's all there is to it! Hopefully this helps you provide more standardized and clear commit messages to your followers, helping your project gain exposure, and help the open source community grow.

Image Credit: Caleb White/Unsplash