glossaryCommit Splitting
The practice of dividing a working-tree change set into multiple discrete commits, each containing one logical unit of work.
explanation
Commit splitting is required when a developer has made several independent changes to their working tree and wants to record them as separate, atomic history entries rather than one large commit. The process involves identifying logical groupings in the diff, selectively staging each group, writing a focused commit message, and repeating until all changes are committed. Manual commit splitting uses git add -p (patch mode) to stage individual hunks, or git add <specific-files> to stage by file. This approach works well for small diffs but becomes tedious with large changes spanning many files. It also requires the developer to mentally plan the grouping before staging. Automated commit splitting tools analyse the entire diff first to plan groups, then execute the staging and committing sequence. Planning before executing is important: it avoids a situation where later groups cannot be described accurately because earlier commits captured too much or too little context.
examples
git add -p # interactive hunk-by-hunk staginggit add src/auth/ && git commit -m 'feat(auth): ...'git add src/api/ && git commit -m 'fix(api): ...'git-agent --intent "..." # discovers, plans, and executes all splitshow git-agent helps
git-agent automates commit splitting end-to-end. It sends the full working-tree diff to the LLM to plan atomic groups, then stages each group's files and hunks, generates a conventional commit message for that group, validates it against the configured hook, and moves to the next group.
brew install gitagenthq/brew/git-agentFAQ
What happens if git-agent splits my changes incorrectly?Does commit splitting work on partial file stages (git add -p hunks)?Is commit splitting useful for solo developers, or only for teams?