glossary

Commit Splitting

The practice of dividing a set of staged changes into multiple discrete commits, each containing one logical unit of work.

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.

git add -p # interactive hunk-by-hunk staging
git add src/auth/ && git commit -m 'feat(auth): ...'
git add src/api/ && git commit -m 'fix(api): ...'
git-agent commit # plans and executes all splits automatically

git-agent automates commit splitting end-to-end. It sends the full staged diff to the LLM to plan atomic groups, then unstages everything, re-stages each group's files and hunks, generates a conventional commit message for that group, validates it against the pre-commit hook, and moves to the next group.

brew install gitagenthq/tap/git-agent
What happens if git-agent splits my changes incorrectly?
git-agent shows you the planned groups before executing. You can abort at the confirmation prompt, adjust your staged files manually, and re-run. The LLM re-plans on each invocation.
Does commit splitting work on partial file stages (git add -p hunks)?
Yes. git-agent reads the staged diff which reflects whatever was staged — whole files or individual hunks. Hunk-level splits are supported in the planner.
Is commit splitting useful for solo developers, or only for teams?
It is valuable for everyone. Solo developers benefit from clean history for their own debugging, for open-source contribution guidelines, and for future maintainers who read the log.