devlk
c/learning u/devlk Team

How should I write Git commit messages?

Team FAQ: this question comes up often, so we've answered it below. Add your own experience, or a different view, in the comments.

Your history is full of "fix", "update" and "changes". What does a good commit message look like?

1
1 comment
No account needed: you'll get a random guest name, kept on this device. Or sign up to choose yours.
Sort by: Best Top New Old
devlk Team·

A good message tells a future reader what changed and why, without opening the diff.

The common format:

Fix duplicate charge when payment webhook retries

Stripe can send the same webhook more than once. We now store the
event ID and skip events we have already processed.

Closes #142
  • Subject line: about 50 characters, written as a command ("Fix", "Add", "Remove", not "Fixed" or "Fixes"), no full stop. A good test: it should complete the sentence "If applied, this commit will..."
  • Blank line, then a body if the change isn't obvious. Explain why, not line-by-line what.
  • Reference the issue when there is one. On GitHub, "Closes #142" in a commit or pull request closes the issue when it is merged into the default branch.

Conventional Commits: many teams use prefixes like feat:, fix:, docs:, refactor: and chore: (for example fix: handle empty cart at checkout). They make changelogs and release tools easier. Follow whatever your team already uses.

Habits that help:

  • One logical change per commit. Use git add -p to stage only the related parts of a file.
  • Clean up before pushing. Messy local commits are fine; squash or reword them before you open a pull request.

Interviewers and reviewers do notice. A clear history in your portfolio projects is a small but real signal (see portfolio projects that impress hiring managers).

Does your team use a commit convention? Share an example below.

1