git-split
Turn one messy branch into a sequence of commits a reviewer can understand.
git-split compares the current branch with its merge base, groups related files
and hunks, lets you reshape the proposal, then builds the commits on a new branch.
The original branch, working tree, and index stay untouched.
Pure Python standard library at runtime. Git is the only external requirement.
Demo scripted and rendered with termreel.
Recorded with termreel; the reproducible source is docs/demo.tape.
$ git split --dry-run
analyzing feature vs main (6 file(s), 7 hunk(s))
plan: 3 commit(s)
1. refactor(assets): update logo.bin [1 file(s), +0 -0]
2. docs(docs): update guide.md [1 file(s), +2 -0]
3. feat(src): add cli.py, helpers.py, parser.py and 1 more [4 file(s), +8 -4]
commit 1: refactor(assets): update logo.bin
assets/logo.bin * | binary
...
dry run: no branch created
Install
python -m pip install git-split-cli
The installed git-split executable is also available as git split because
Git discovers executables named git-* on PATH.
The PyPI distribution is named git-split-cli; the shorter git-split
distribution name belongs to an unrelated project.
Use
From the messy branch:
git split # edit the proposal in $EDITOR, then execute
git split --edit prompt # use the built-in line-oriented editor
git split --dry-run # inspect the proposal; change nothing
git split --base origin/main # choose the comparison base explicitly
git split --branch clean-pr # choose the output branch name
By default the tool detects origin/HEAD, origin/main, origin/master,
main, master, or develop, then compares HEAD with the selected ref's
merge base. If the proposed output name already exists, a numeric suffix is
added instead of overwriting it.
For a reviewable two-step workflow, write the plan to disk and execute it later:
git split --write-plan split.plan
$EDITOR split.plan
git split --use-plan split.plan
The plan resembles an interactive-rebase todo file. Move hunk lines between commit blocks, reorder blocks, and edit messages. Validation rejects plans that drop or duplicate any change.
commit 1: fix(parser): normalize tokens
src/parser.py #1 | @@ -8,7 +8,7 @@ def parse(text):
commit 2: refactor(output): render values with repr
src/parser.py #2 | @@ -24,7 +24,7 @@ def emit(items):
Whole-file entries use *. Binary files, renames, additions, and deletions are
atomic and always appear this way.
How grouping works
Candidate commits combine four deterministic signals:
- directory proximity;
- identifier overlap in changed lines;
- Python and JavaScript/TypeScript import relationships;
- files that changed together in recent history.
After file clustering, individual hunks can move to a better-matching cluster.
Use --file-level to disable hunk splitting, --threshold to tune clustering,
or edit the plan directly when intent beats heuristics.
Safety model
Execution creates a temporary Git worktree at the merge base and stages each
planned patch with git apply --cached. Commits are created only on the new
branch. If reordered hunks conflict, that file is regrouped into its earliest
commit and execution restarts. If execution still fails—or if the final tree is
not byte-identical to the original tip—the incomplete branch is removed.
--dry-run does not create a branch or commit. Hooks are skipped for generated
commits so local hooks cannot modify the reconstructed tree.
Options
--base REF base ref (otherwise auto-detected)
--branch NAME output branch (default: <current>-split)
--dry-run print the plan and make no changes
--edit MODE auto, editor, prompt, or none
--threshold N clustering threshold from 0 to 1
--file-level keep every file atomic
--write-plan FILE save a plan and exit
--use-plan FILE validate and execute an edited plan
--history-limit N history commits used for co-change analysis
-y, --yes skip confirmation
Development
python -m pytest -q
# or
make test
The tests build real repositories in temporary directories and exercise binary patches, renames, hunk reordering, fallback behavior, editor validation, dry runs, and preservation of the source branch.
MIT license.
Metadata
Release files for git-split-cli 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| git_split_cli-0.1.1.tar.gz | 26.1 kB | With provenance | Details for git_split_cli-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| git_split_cli-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for git_split_cli-0.1.1-py3-none-any.whl |
Total release size: 50.1 kB
Release files / git_split_cli-0.1.1.tar.gz
| Download URL | git_split_cli-0.1.1.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e901fe07d100a55c3e7974ae3f0d3cabb9c8000ddb915752711b22de6e60fc64
|
|
BLAKE2b-256 checksum How to use checksums |
a9e4fdf62acd2b3c7b6688b24ac84a99ab22732e81511f7cb0d58083b05a3e90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logRelease files / git_split_cli-0.1.1-py3-none-any.whl
| Download URL | git_split_cli-0.1.1-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ae121e9246a5cca34bf91978f191bba494454c951a645d1b37559466232de53
|
|
BLAKE2b-256 checksum How to use checksums |
e170f9a184a491cdc4c90a03ea96fe13b15bfc2923793c6d7ee96e8efd8a9c2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logSecurity for git-split-cli 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for git_split_cli-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.