Git Workflows and Developer Best PracticesLesson 6.2
How to write good Git commit messages
conventional commits format, type prefix, subject line rules, body and footer, git log --oneline, amending commits, atomic commits, why commit messages matter
Writing Good Commit Messages
Good commit messages make code review faster, debugging easier, and automated changelogs possible. The Conventional Commits format is the industry standard.
The format
type(scope): short description
[optional body]
[optional footer]Common types
feat: a new feature
fix: a bug fix
docs: documentation changes only
chore: build process, dependency updates
refactor: code change that neither fixes a bug nor adds a feature
test: adding or updating testsGood vs bad examples
# Bad
git commit -m "fix stuff"
# Good
git commit -m "fix(auth): prevent token refresh loop on expired session"
git commit -m "feat(api): add pagination to /users endpoint"Subject line rules
Keep the subject under 72 characters. Use imperative mood: add not added. Do not end with a period.
Amending the last commit
git commit --amend -m "fix(auth): correct token expiry check"Only amend commits that have not been pushed to a shared branch.
