code

How should I name my Git commit messages?

Yashu Mittal

These are fantastic questions! I can’t stress enough how important it is to spend some time writing a good commit message.

Now, what makes a “good” commit message? That’s a great question and has been written about a number of times. Here are some important things to think about when crafting a good commit message:

Do

Do not

The best way that I’ve found to come up with a commit message is to finish this phrase, “This commit will…“. However, you finish that phrase, use that as your commit message.

If you need to explain why a change is being made or how does it address the issue?

You can add a blank line, separating the commit message from description.

When you’re writing the commit message, the first line is the message itself. After the message, leave a blank line, and then type out the body or explanation including details about why the commit is needed (e.g. URL links).

Git is smart enough to distinguish the first line of your commit message as your summary. In fact, if you try *git shortlog*, instead of *git log*, you will see a long list of commit messages, consisting of the id of the commit, and the summary only.

Further paragraphs come after blank lines.

Here’s what a commit message edit screen might look like:

Git Commit Message Example

Response to “How should I name my Git commit messages?”

Stay current

Sign up for our newsletter, and we'll send you news and tutorials on business, growth, web design, coding and more!