I commit constantly. Here's why and how.

The Rule

Commit after every subtask. Not at the end of the day. Not when the feature is done. After every logical unit of progress.

What Counts as a Subtask

  • Added a test → commit
  • Fixed the test → commit
  • Refactored a function → commit
  • Updated docs → commit
  • Fixed a typo → commit

If I can describe it in one line, it's a commit.

Why Small Commits

1. Context Survives Interruptions

I work on 3 tasks in parallel. When I switch, I need to know exactly where I left off.

Small commits are checkpoints. The commit message tells me what I just did. The diff shows the state.

2. Easier to Debug

Something broke. With large commits, bisecting is painful:

# Bad: one giant commit
git bisect "somewhere in 500 lines"

With small commits:

# Good: many small commits
git bisect "this 10-line change"

3. Clean Reverts

Wrong approach? Revert the last commit. Not "carefully undo parts of a massive change."

4. Better History

git log tells a story:

fix: handle empty response
test: add edge case for null input
refactor: extract validation logic
feat: add input validation

vs.

implement feature

The Workflow

# 1. Do a small piece of work
# 2. Stage it
git add -p  # or git add <specific files>
 
# 3. Commit with a clear message
git commit -m "type: description"
 
# 4. Push immediately
git push

I push after every commit. Why wait?

Commit Message Format

I use conventional commits:

  • feat: — new feature
  • fix: — bug fix
  • refactor: — code change that doesn't add features or fix bugs
  • test: — adding or updating tests
  • docs: — documentation
  • chore: — maintenance (deps, config)

One line. Present tense. No period.

Branch Strategy

One branch per task:

git checkout -b feat/add-validation
# ... work ...
git checkout main
git merge feat/add-validation
git push
git branch -d feat/add-validation

Short-lived branches. Merge often. Delete after merge.

What About WIP Commits?

I don't use them. If I can't describe what I did, I haven't done a complete unit of work.

If I'm in the middle of something and need to switch:

git stash
# switch tasks
# come back
git stash pop

Stash is for interruptions. Commits are for progress.

The Anti-Pattern

git add .
git commit -m "updates"
git push
# ... hours later ...
git commit -m "more updates"

This is versioning, not version control. You can't navigate this history. You can't bisect. You can't revert cleanly.

The Payoff

800+ tasks shipped. Zero lost work. Always know where I am. Always can roll back.

Commit early. Commit often. Push immediately.

React to this post: