Trusted answers to developer questions

Git commit message: simply explained

Get Started With Data Science

Learn the fundamentals of Data Science with this free course. Future-proof your career by adding Data Science skills to your toolkit — or prepare to land a job in AI, Machine Learning, or Data Analysis.

Recently I published a Simply Explained article that worked to expand on some context I felt was missing from the web. This article did so well on Dev.to that I wanted to extend the series!

📇Table of Contents

What is commit message❓

If you use Git/GitHub as your version control and understand the basics, you might have already heard of commit messages. If you are new to GitHub, click here to understand the basics. A commit in GitHub is described as a saved change. A commit message explains what change you made to your project. It is greatly important to learn how to make a good commit message no matter if it is a personal or professional project.

Why are commit messages important?🙋‍♂️

I do have to give credit to my coding boot camp instructor for teaching me how to write good commit messages. He made me well aware of the importance of a well-structured commit message. During my time at my coding boot camp, I was corrected each time I had a bad commit message rather than saving everything to one commit or a poor commit sentence. Since then, I always spend a few extra minutes to make sure I have a good commit.

1. Easily obtainable for other projects

Have you ever encountered a bug that you had fixed in the past, but can’t remember how? Have you ever had a project that you were working on and realized that you built this component before? A good commit message can easily be found when you need it later. You can develop a pattern to easily find it and see what you did to duplicate what you need.

2. Easily understandable for other developers

Alt Text

Most of us have been guilty of writing bad commit messages just because “I know what this message means 💅.” That is great that you understand the commit message, but what if you are reaching out for assistance from other developers and they have a hard time understanding the process you took because you saved 80% of your project under one commit called "stuff working"🙅‍♂️? This is especially troublesome when you are working professionally with a team of developers or contributing to open-source projects. A good commit message could be the difference between a knowledgeable developer and a beginner.

3. Great way to learn!

The best way to learn how to code is by not remembering everything, but by understanding what you are coding. The best way to write your commit message is to make it about what your code is achieving.

How to make good commit messages?👨‍🏫

Commit message humor

You understand why commit messages are important, but how exactly do you make good commit messages? It does not have to be difficult to write good commit messages. The most important rule to learn is to COMMIT EARLY, COMMIT OFTEN. Start your commit every time you fix a bug, console log your data, style your components, etc. It is very important to have viable commits. My favorite tool for this is GitKraken as it is a GUI that splits up your commits.

The three ingredients🔥

Commit message example

1. Emoji

It took me months before I started putting emojis on my commit messages. However, I have since realized how much adding an emoji can benefit commit messages. It has made my commit messages easy to grasp, understandable, and cleaner. The best emoji to use is one that is related to your commit message such as 🐛 for a bug fix or 💄 for styling your components. 🔖Click this for a cheat sheet on the best emoji to use for commit messages.

2. Verb

The next ingredient is to add an imperative verb to your message. Good examples are “Add”, “Fix”, “Restructure”, etc. Never add “-ed” or “-ing” to your message like “Added” or “Adding”. Your verb should start with a capital letter as well.

3. Object

What are you fixing? What are you styling? What did you add? Unless necessary, this should be stated in one or two words such as “components”, “home page”, “images”, etc.

Examples of a good commit.📽

Commit messages are not difficult to make. Using these three ingredients, you can make excellent commit messages that are clean and easy to understand. Below is an example of a good commit.👇

widget

Thank You

If this article provided any value to you, please leave a ❤ or let me know your thoughts! Follow me to keep up when I post more articles as I will be posting five days a week until further notice. Let me know what other topics I can simply explain to you!

RELATED TAGS

beginner
git
github
Did you find this helpful?