Guides/Web Development
Web Development5 min read

How to Write Good Git Commit Messages

Good commit messages make code reviews faster, debugging easier, and teammates happier. This guide covers the standard commit message format, conventional commits, and the rules that separate professional teams from amateur ones.

The Seven Rules of a Great Commit Message

Separate subject from body with a blank line. Limit the subject line to 50 characters. Capitalize the subject line. Do not end the subject line with a period. Use the imperative mood ("Add feature" not "Added feature"). Wrap the body at 72 characters. Use the body to explain what and why, not how. These rules make git log readable and make your history useful as documentation.

Use Conventional Commits Format

The Conventional Commits spec is the industry standard: type(scope): description. Types: feat (new feature), fix (bug fix), docs (documentation), style (formatting), refactor (code restructure without feature change), test (adding tests), chore (build process, dependencies). Examples: feat(auth): add Google OAuth login — fix(api): handle null user in booking endpoint — chore: upgrade Next.js to 14.2. This format enables automated changelogs and semantic versioning.

Write the Body When the Subject Is Not Enough

Not every commit needs a body — but when the why is not obvious, explain it. Bad: "Fix login bug". Good subject: "Fix session not persisting after OAuth callback" — Good body: "The OAuth callback was setting the session cookie before the redirect, causing browsers to drop it. Setting the cookie after the redirect response resolves this for Chrome and Safari. Firefox was unaffected." The body is for future-you and your teammates.

Reference Issues and PRs

Link commits to work items: "Fixes #123" or "Closes #456" in the commit body automatically closes the linked GitHub issue when merged to the default branch. "See #789" creates a reference without closing. "Co-authored-by: Name <email>" credits a pair programming partner. These links create traceable connections between code changes and the business reasons behind them.

Need Help?

Want this done for you?

Our engineering team handles implementations like this every week. Get a free scoping call — we will tell you exactly what it takes and what it costs.

Book a free call

© 2026 NexWorldTech — Built for Global Dominance.