Commits are communication. Teams read git log --oneline during incidents and reviews.
Good commit subjects
- Imperative mood: “Add validation”, not “Added”.
- One logical change per commit when possible.
- Reference ticket IDs if your team uses them.
Never commit secrets
API keys in history require rotation and painful scrubbing. Use .env locally and gitignore it.
Self-check
- Rewrite a vague message like “fix stuff” into a clear subject.
- What should you do if you accidentally committed a password?
Interview prep
- What does a good commit subject line look like?
Short (often ~50 characters), imperative mood (“Add validation”), and specific enough that someone scanning
git log --onelineunderstands intent without opening the diff.- Why should you never commit API keys or passwords?
Repos are copied and searched; history is hard to purge fully. Use environment variables, secret managers, and rotate credentials if leaked.