CLSkills
Git & Version Controladvanced

Commit Splitter

Share

Split a large commit into smaller, logical commits

Commit Splitter

Split a large commit into smaller, logical commits

Split a large commit into smaller, logical commits.

Instructions

  1. First, undo the large commit but keep changes:
git reset --soft HEAD~1     # if it's the latest commit
# or
git reset --soft <commit>   # for a specific commit
  1. View all staged changes:
git diff --staged --stat    # overview
git diff --staged           # details
  1. Identify logical groups:

    • Separate refactoring from feature changes
    • Separate test additions from implementation
    • Separate dependency updates from code changes
    • Separate formatting from logic changes
  2. Unstage everything, then add back in groups:

git reset HEAD .                           # unstage all
git add src/auth/login.ts src/auth/types.ts  # group 1: auth logic
git commit -m "feat(auth): add login endpoint"

git add tests/auth/                          # group 2: tests
git commit -m "test(auth): add login tests"

git add package.json package-lock.json       # group 3: deps
git commit -m "chore: add bcrypt dependency"
  1. For partial file staging:
git add -p filename    # interactive hunk selection

Rules

  • Each commit should build and pass tests independently
  • Each commit should have a clear, single purpose

Quick Info

Difficultyadvanced
Version1.0.0
AuthorClaude Skills Hub
gitcommitrefactoring

Install command:

curl -o ~/.claude/skills/commit-splitter.md https://claude-skills-hub.vercel.app/skills/git/commit-splitter.md