Git Commit Best Practices Guide
Message format, commit types, and conventions.
Message Format
Subject Line
50 chars max, imperative mood
Example: Add login validation
Body
Wrap at 72 chars, explain why
Example: Separate paragraphs with blank line
Footer
Reference issues, breaking changes
Example: Refs: #123, BREAKING CHANGE: api
Commit Types (Conventional)
feat: New feature
fix: Bug fix
docs: Documentation
style: Formatting, no code change
refactor: Code restructuring
test: Adding tests
chore: Maintenance tasks
Best Practices
One logical change per commit
Write subject first
Use imperative mood
Don't end subject with period
Limit subject to 50 chars
Separate subject from body
Explain why not how
Reference related issues
Common Mistakes
✗ Vague messages
✗ Multiple changes per commit
✗ Past tense verbs
✗ Too long subjects
✗ Missing context in body
✗ No issue references
✗ Committing broken code
✗ Huge monolithic commits
Commit Message Examples
Good: 'feat: Add user authentication' - clear, specific. Good: 'fix: Resolve null pointer in payment' - what fixed. Good: 'refactor: Simplify validation logic for readability' - why. Bad: 'Fixed stuff' - vague. Bad: 'WIP' - not useful. Bad: 'Changes' - no context. Commit message = communication. Future developers read this. Write for them, not just yourself. Clear, specific, explain why."