Example result: Write clear git commit messages
AI-generated example · Commit Messages
Updated

Write clear git commit messages

This prompt writes commit messages for your changes. Paste the diff or a description and choose a convention, and it gives a summary line under 72 characters in the imperative mood, plus a body where needed.

text-git-commit-messages — chatgpt — 51 words

Write git commit messages for these changes.

Changes: [PASTE DIFF OR DESCRIBE]
Convention: [CONVENTIONAL COMMITS / PLAIN]

Give a summary line under 72 characters in the imperative mood, then a short body explaining why the change was needed. Suggest splitting into multiple commits if the change does more than one thing.

Explain why in the body. The diff already shows what changed.

Get a better result

What you will get

A summary line under 72 characters in the imperative mood, a short body that explains why the change was made, and a suggestion to split the work into separate commits if it does more than one thing.

Why it works

The imperative mood and the 72 character limit are long standing git habits, and they keep history readable in tools that cut long lines. The body is about why because the diff already shows what. Asking whether to split is the hidden gem: small commits are easier to review and to undo.

Common mistake

The body repeats what the diff shows.

Fix: Tell it the reason behind the change, like a bug report or a user request, and ask it to explain only that, as the tip says.

Also watch for
  • The summary says “Update files”. Ask for a summary that names the behaviour that changed, so it still makes sense in a list of fifty commits.
  • The conventional commit type is wrong. Ask it to pick fix only for a bug users could hit, and feat only for something new they can do.
Try a variation: write a pull request

Paste the commit messages and ask for a pull request description with a summary, how to test it and anything reviewers should check.

Still not right? Reply with this

Split this into separate commits. List which files go in each one and write a message for each.

More chat & writing prompts

See all 465 →