My git hygiene is poor: giant commits, vague messages, and junk committed alongside
In one sentence: I may mix unrelated edits, artifacts, or sensitive files into a large commit with a vague message; inspect the real index and organize verifiable logical changes while preserving preexisting work.
Symptom
Here's how it tends to end: you ask me to "finish this feature," I head down for twenty minutes, touch a dozen files, and then do one git add -A && git commit. You open the history and find:
- One giant commit: the login logic, a utility function I refactored along the way, a new dependency, a config change, plus the imports I reordered — all crammed into the same commit, a 1,000-plus-line diff.
- A message that says nothing: the commit message is "update code" / "fix stuff" / "various changes" — it tells you something changed, but not what or why.
- Junk swept in too: artifacts under
dist/andnode_modules/, atmp.logI generated while debugging, even a.envwith real credentials, and a whole block of dead code I commented out "just in case" — all scooped up bygit add -A.
Each commit "runs" on its own, but the history as a whole is no longer usable.
Why this happens
I may interpret completion as saving the whole working tree without distinguishing preexisting changes, my changes, generated artifacts, and sensitive files. Bulk staging can mix unrelated content in one commit; inspect the actual index rather than trusting a tool's summary.
Pro Git recommends logically separate changesets and messages that explain intent. Conventional Commits provides a machine-readable message convention. These are collaboration practices, not evidence that all models lack commit discipline or that each file/edit needs its own commit.
I should follow the project's existing convention and the user's authorization, organize changes that can be understood and validated independently, and inspect the staged diff before committing.
Consequences
git bisectis dead. It works by bisecting commit by commit to pinpoint which one introduced a bug. When a commit stuffs in eight unrelated things, even if the bisect lands on it you still don't know which of the eight is the culprit — your precision drops back to "read a 1,000-line diff by hand."- Rollback becomes guilt by association. You only want to revert that one buggy utility-function change, but it's bound to the login logic in the same commit. One
git revertand you've reverted the good parts too. - Code review exists in name only. A reviewer facing a 1,000-line diff spanning eight concerns can't review it seriously — they either wave it through or just LGTM. Only small, atomic commits are reviewable.
- A message with no information strips the history of navigational value. Six months later you
git logto find "why did we change the timeout to 60 seconds back then" and you see a row of "update code / fix stuff." The history was supposed to be the project's record of decisions; now it's degraded into noise. - Things mixed into the repo cost extra to clean out. Artifacts bloat the repo; dead code misleads whoever comes next; and once a
.envis in the Git history, deleting one line isn't enough — that secret has leaked and must be rotated (see the security entry above).
What to do instead
Conclusion first: don't let me accumulate one big commit. Require small, atomic commits, make each message explain why, and have me list the plan for your review before committing.
-
Require small, atomic commits — one thing per commit. Say it directly: "Split this into multiple commits along logical changes, one thing per commit, and don't stuff unrelated changes into the same commit." I do listen to this kind of explicit constraint; without it, I'll
addeverything in one go. -
Have me list the plan before committing, and commit only after you nod. One line does it: "Before committing, list which files and which changes this commit includes and why they belong together; wait for my confirmation before you commit." This step intercepts the giant commit before it lands, and incidentally forces me to surface the things that shouldn't be in the repo.
-
Commit messages must explain why; you can adopt Conventional Commits. Require me to use an imperative subject under 50 characters summarizing what was done, and a body that explains why the change was made and what prior behavior it replaces — exactly the Pro Git commit guideline. If you want machine-readable messages and auto-generated changelogs, adopt the Conventional Commits format:
<type>[scope]: <description>, with breaking changes flagged by!or aBREAKING CHANGE:footer. -
Use
.gitignoreplus a pre-commit check to block artifacts, secrets, and temp files. Putdist/,node_modules/,.env,*.log, and friends in.gitignore, and require me to "rungit statusbefore committing to see exactly which files will be committed, exclude any artifacts / secrets / temp files, and never usegit add -Ato scoop everything blindly." -
Break large changes into independently reviewable commits. Don't mix a refactor with a new feature: first a "pure refactor, no behavior change" commit, then an "add new feature" commit. Each can be reviewed on its own and reverted on its own.
# Don't instruct me like this (I'll accumulate a giant commit + "update code")
Finish this feature, then commit
# Instruct me like this (small atomic + plan-then-commit + explain why)
When done, split it into multiple atomic commits along logical changes, one thing per commit.
Before committing, run git status to list the files that will be committed, and exclude artifacts / .env / temp files.
Use Conventional Commits format for each message, with a body explaining why the change was made.
List the plan and wait for my confirmation, then commit one by one.
Also: .gitignore does not affect tracked files. Inspect git diff --cached and secret-scan results. Routine commits already covered by authorization can proceed under the agreed policy without repeated confirmation; shared history must not be rewritten by default.
Example
Before:
You: Finish the shopping-cart checkout feature
Me: (changed 12 files: checkout logic, a price util I refactored along the way, a new
dependency, a debug console.log, the generated dist/, and a .env with credentials)
Me: git add -A && git commit -m "update code"
You: ...how many separate things are in this one commit? Which parts are checkout, which aren't? How did .env get in?
$ git log
a1b2c3d update code # 1,200 lines, 12 files, includes .env and dist/
After:
You: Finish cart checkout. Split into atomic commits, and list the plan for me before committing.
Me: I plan 3 commits — confirm the scope first:
1. refactor(cart): extract the price calculation util (pure refactor, no behavior change)
2. feat(checkout): implement the checkout flow
3. chore: add dist/, .env, *.log to .gitignore
Note: I found a .env with credentials and the build artifacts under dist/ in the working tree.
These don't belong in the repo, so I've added them to .gitignore and won't commit them. Confirm this split?
You: Confirmed
Me: (commits one by one, each message's body explaining "why the change was made")
$ git log
3c4d5e6 feat(checkout): add cart settlement with tax + coupon
2b3c4d5 refactor(cart): extract price calculation into pure util
1a2b3c4 chore: ignore build artifacts and local env files
The difference isn't that I got more careful — it's that before the giant commit lands, there's now a process to "split first, list the plan, and let you call a halt," and .env and dist/ got blocked before they ever entered the repo.
When the exception applies
"Small, atomic, message explains why" is the default, but the value of commit granularity comes from "someone will read this history later." When that premise doesn't hold, forcing atomic commits is just waste:
- A throwaway spike / probe branch destined to be squashed whole: you're only checking whether an idea pans out, the branch is use-and-discard, and merging it
squashes everything into one commit. Nobody reads the granularity of the intermediate steps, so piling them into a heap of scratch commits is actually less work. - WIP checkpoints, purely for your own save points: in a long task I
commit -m "wip"every so often just to have an anchor I canresetback to, with no intention of it entering the real history — I'llrebaseand clean it up before merging. - Machine-generated, wholesale-replaced artifacts: lock files, a
generated/directory, anything regenerated as one whole slab — splitting it into commits carries no semantic value, and a single "regenerate X" commit is the clearest record.
But every one of these assumes "this history is private and will be rewritten or squashed before it hits the main line." The test, in one line: the moment these commits enter someone else's git bisect, git blame, or code review as-is, the exception is off — go back to small, atomic, explain-why.
Tool differences
Claude Code checkpoint documentation checked on 2026-10-29 covers files edited with its file tools in the current conversation; subsequent Bash or external changes to those files may also be reverted. Files touched only through Bash, some subagent edits, and symlink/hard-link paths have different coverage.
Inspect the restore menu, current diff, and target files first. "Restore code" does not promise to undo only my last edit. Other products' checkpoints, editor buffers, and Git undo behavior require verification for the installed version rather than an outdated cross-product default table. Durable history and collaboration still need version control.
Version notes
Rechecked Conventional Commits 1.0.0, Pro Git, and current Claude Code checkpoint documentation on 2026-10-29. Retained atomic logical commits and index inspection; .gitignore does not untrack files, and exposed credentials require rotation. Validate recovery tools separately; they neither replace durable history nor authorize rewriting shared history.