r/git • u/TheSaasDev • 2d ago
subcommit - commit only a subset of files/lines while preserving unrelated staged, unstaged, and untracked work
Enable HLS to view with audio, or disable this notification
Repo: https://github.com/reemus-dev/subcommit
To solve the pain of committing a subset of changes that arise from working with multiple concurrent agents and user edits. Yes, you could use worktrees, which is wonderful and has its place, but sometimes I just want life to be easier.
I have been using it for a few months now and decided to open-source it. Hope others find it useful too! Much less stressful than watching agents do all kinds of gitfoo to just commit their changes.
15
u/lego3410 2d ago
I respect your works, but honestly I feel vanilla git and worktree much easier.
-1
u/TheSaasDev 2d ago
Understandable. I really just wanted the IDE commit tool in a CLI
5
u/IrrerPolterer 2d ago
But this already exists in vanilla git... You can stage parts of a file with
git add -p
8
2
u/schmurfy2 2d ago
lazygit does that fairly well if you don't want an ide and not want to use the git cli directly.
0
u/donk8r 2d ago
You're right that -p being interactive is the actual problem, and nobody here engaged with that.
What I'd design against is that a filtered commit produces a tree that never existed on disk. Just tried it, agent A's rename committed clean and green while the worktree still had agent B calling the old name. Nobody ever ran the thing that got committed.
1
u/TheSaasDev 2d ago
Fair criticism, a filtered commit can produce a tree that differs from the current worktree, so it may not be the exact tree that was tested.
Pretty sure this applies even when using `git add -p` and the IDE's partial-commit tools.
If every agent’s commit must be independently runnable before it’s created, a separate worktree makes more sense. Personally, I find I don't have this requirement most of the time when working.
1
u/elephantdingo 1d ago
There’s the active voice, the passive voice, and the passivest voice/LLM voice.
19
u/me_hq 2d ago
git add -p ?