foundation
Commit
Create small immutable snapshots with clear intent, authorship, parent links, and reviewable diffs.
A Git commit is an immutable snapshot plus metadata: parent commit IDs, author, committer, message, and a tree object pointing at file blobs. Commits form a directed acyclic graph — each commit knows its parent(s), not the other way around.
git add src/auth.ts
git commit -m "fix(auth): reject expired refresh tokens"
Good commits represent one logical change that can be reviewed, reverted, cherry-picked, and explained months later. Staging (`git add -p`) lets you split mixed working-tree edits into separate commits.
On interviews: explain commit identity (SHA-1 hash of content), why small commits help review and bisect, and how history supports release traceability.
Common pitfalls: huge mixed commits that hide rollback targets; rewriting public commits without coordination; committing secrets or generated artifacts that belong in `.gitignore`.
The trade-off is granular history (more commits) versus review noise — the unit should be logical, not microscopic.
Checklist:
- Explain commit identity and parent links.
- Keep one logical change per commit.
- Separate formatting churn from behavior changes.
- Stage deliberately with patch mode when needed.