पाठ 19 / 25
Clean Commits and History
A history a reviewer can read.
Small, focused, well-described
Your commit history shows how you work. Good habits: small, focused commits that each do one thing, clear messages with a short summary line in the imperative mood ("Add retry to email sender") and a body explaining why when it is not obvious, and no secrets or generated files committed (use a .gitignore). Use branches and pull requests even on solo projects to practise the workflow, and write a short description on each pull request. You do not need to rewrite old history perfectly, but avoid a portfolio where every commit says "update" or "fix" with hundreds of unrelated changes.
Show how you work, not just what you built
Commit history, tests, CI and open source contributions show working habits a reviewer can see.
Weak and clear history
Commit messages shown for comparison.
Hard to read:
a1b2c3d update
d4e5f6a fix
0a1b2c3 more changes
3c4d5e6 final final
Easy to read:
9f8e7d6 Add Flyway migration for release_notes table
8e7d6c5 Validate note title length on create and update
7d6c5b4 Fix RSS feed date format to RFC 822
6c5b4a3 Add integration tests for publish workflow
5b4a392 Document local setup and env variables in README
Message shape:
<summary in imperative mood, about 50 characters>
<optional body: why the change was needed and any trade-offs>Scan for secrets before going public
Before making a repository public, check its history for API keys or passwords. If a secret was ever committed, revoke and rotate it; deleting the file in a new commit does not remove it from history.
त्वरित जाँच: Which commit message is most useful to a reviewer?
- stuff
- update
- final final
- Validate note title length on create and update
Answer
Validate note title length on create and update — Clear messages show what changed.