Script Valley
Open Source Contribution: A Practical Guide
Git Workflow for ContributorsLesson 2.3

How to write commit messages that get PRs merged faster

Conventional Commits spec, subject line rules, body and footer format, breaking changes, issue references, atomic commits, amend and rebase for cleanup

Why Commit Messages Matter

Commit messages are permanent. They appear in git log, changelogs, and release notes. A good message tells future developers -- and automated tools -- exactly what changed and why.

The Conventional Commits Format

# Format: type(scope): short description
# Body: optional -- explains WHY, not WHAT
# Footer: issue refs, breaking changes

fix(auth): prevent null pointer on logout with expired session

The session token was being read after expiry check failed,
causing a NullPointerException in AuthService.logout().
Added null guard before token access.

Fixes #234

Valid types: feat, fix, docs, style, refactor, test, chore. Scope is optional but useful: feat(api), fix(parser).

Rules for the Subject Line

Keep it under 72 characters. Use the imperative mood: add feature not added feature. Do not end with a period. Reference the issue in the footer, not the subject.

Cleaning Up Before PR

# Amend the last commit message
git commit --amend

# Squash multiple WIP commits into one clean commit
git rebase -i HEAD~3

Never push WIP commits labeled fix, wip, or temp to a PR. Squash them into meaningful commits before requesting review.

Up next

How to handle merge conflicts in a pull request

Sign in to track progress

How to write commit messages that get PRs merged faster โ€” Git Workflow for Contributors โ€” Open Source Contribution: A Practical Guide โ€” Script Valley โ€” Script Valley