4 releases
Uses new Rust 2024
| 0.1.3 | Mar 22, 2026 |
|---|---|
| 0.1.2 | Mar 21, 2026 |
| 0.1.1 | Mar 21, 2026 |
| 0.1.0 | Mar 21, 2026 |
#624 in Artificial intelligence
125KB
3.5K
SLoC
git-hunk
git-hunk is a small Rust CLI for non-interactive hunk staging.
It lets you scan diffs, inspect exact changes, stage or unstage precise selections, and preview commits without using git add -p.
Install
From crates.io:
cargo install git-hunk
From GitHub:
cargo install --git https://github.com/nexxeln/git-hunk.git
Binary installer:
curl -fsSL https://raw.githubusercontent.com/nexxeln/git-hunk/main/install.sh | sh
Commands
scanlists selectable hunks and changes and returns asnapshot_idshowprints a hunk,change_id, orchange_keyresolvemaps a file and line hint to matching selectorsvalidatechecks whether selectors still match the current snapshotstagestages selected hunks, changes, change keys, or line rangesunstageremoves selected hunks, changes, change keys, or line ranges from the indexcommitstages a selection and commits it, or previews it with--dry-run
Example
git-hunk scan --mode stage --compact --json
git-hunk show --mode stage <change-key> --json
git-hunk stage --snapshot <snapshot-id> --change-key <change-key> --dry-run --json
git-hunk stage --snapshot <snapshot-id> --change-key <change-key> --json
Notes
- Mutating commands require a fresh
snapshot_id change_idis snapshot-bound;change_keyis more stable across rescans- Unsupported paths like conflicts, renames, and binary diffs are reported instead of forced through
Build
cargo build
Release
On every push to main, GitHub Actions runs tests, publishes a new crates.io version when Cargo.toml has an unpublished version, and creates a matching GitHub release with binary archives.
Dependencies
~4–11MB
~235K SLoC