Git subcommand for change-centric workflows.
Project description
git-surgeon
A Git subcommand for change-centric workflows, borrowing ideas from Jujutsu’s change‑centric UX while staying within Git’s history model.
Install
For development, install the project in editable mode:
pip install -e .
Or copy the wrapper script onto your PATH:
chmod +x git-surgeon
cp git-surgeon ~/bin/
Then you can call it as a Git subcommand:
git surgeon --help
Usage
git surgeon <command> [options]
Run git surgeon <command> --help for command-specific help.
Commands
Diff a commit
git surgeon diff <commit> --head -- path/to/file
Compare a commit to its parent or to HEAD.
Show a file at a commit
git surgeon show <commit> path/to/file
Prints the file contents as they existed in the commit.
Show reflog entries
git surgeon op log --count 20
Displays the recent reflog operations.
Restore a reflog entry
git surgeon op restore HEAD@{1}
Resets the repo to a specific reflog entry.
Abandon a rebase
git surgeon op abandon
Resets the repo to the commit before the last rebase.
Revert a commit via operation history
git surgeon op revert HEAD
Creates a new commit that reverts the specified commit.
Save WIP without stashing
git surgeon stashless --message "WIP: refactor" --keep-branch
Creates a WIP commit on a temporary branch.
Create a new empty commit
git surgeon new -m "WIP"
Creates an empty commit without staging changes.
Undo last git operation
git surgeon undo --hard --steps 1
Resets HEAD to a previous reflog entry.
Go to the commit before a rebase
git surgeon pre-rebase --hard
Resets to the commit before the last rebase.
Resolve the current operation
git surgeon resolve --continue
Continues, aborts, or skips the active rebase/merge/cherry-pick.
Reword a commit
git surgeon reword <commit> "New message"
Quickly amend the commit message with a new one.
Describe a commit message
git surgeon describe <commit> -m "Updated message"
reword requires a new message and amends immediately, while describe can
open the editor and keep the original dates.
Edit a commit
git surgeon edit <commit>
Stops an interactive rebase at the commit, keeps the original dates, and
prompts you to amend. Add --message to update the message immediately.
Set commit dates
git surgeon metaedit date <commit> "2024-01-01T12:00:00Z"
Sets committer date by default (RFC2822 or RFC3339). Use -a for author dates
or -ca to set both.
Set commit author
git surgeon metaedit author <commit> "New Author"
Updates the author name without changing content.
Set commit author email
git surgeon metaedit mail <commit> "new@example.com"
Updates the author email without changing content.
Absorb staged changes
git surgeon absorb
Creates a fixup commit and autosquashes into the latest touching commit.
Squash a commit into its parent
git surgeon squash <commit>
Squashes the commit into its parent with interactive rebase.
git surgeon squash <commit> --into <target>
Squashes the commit into a specific ancestor.
Fixup a commit into its parent
git surgeon fixup <commit>
Fixups the commit into its parent, discarding its message.
Drop a commit
git surgeon drop <commit>
Drops the commit via interactive rebase.
Merge a commit or branch
git surgeon merge <commit>
Merges another commit or branch into the current branch.
Split a commit into two
git surgeon split <commit>
The tool resets the commit, then asks you to stage and create two new commits.
Use --first-message and --second-message to set messages automatically.
Split a commit interactively
git surgeon split -i <commit>
Uses git add -p for the first split commit.
Swap two commits
git surgeon swap <commit-a> <commit-b>
Swaps two commits in a linear history.
Move a commit after another
git surgeon move <commit> <destination> --before
Moves a commit before or after another in linear history.
git surgeon move <commit> <destination> --onto
Moves a commit and its descendants onto the destination.
Untrack a file (keep it on disk)
git surgeon file untrack path/to/file
Removes the file from the current commit while keeping it on disk. Use
--from <commit> or --root to rewrite history.
Track a file
git surgeon file track path/to/file
Starts tracking the file in the current commit. Use --from <commit> or
--root to rewrite history.
Notes
edit,reword, andsplitpreserve original author/committer dates.squashandfixupuse the default interactive rebase behavior for messages.swapexpects the commits to be on the same ancestry path.moveexpects the commits to be on the same ancestry path.file trackandfile untrackonly rewrite history when--fromor--rootis provided.metaedit datesupports-a/-cwith the special valuesauthor/committo swap dates.pre-rebaseusesORIG_HEADor the reflog entry for rebase start.op restore --pre-rebaseorop restore pre-rebaseuse the same target.op revert --pre-rebaseorop revert pre-rebaserevert that target.- If a rebase is already in progress, the tool will exit with an error.
- Most commands that take a commit accept
-r/--commitas an alias for the commit argument. describealso acceptsdesc, andsplit -ienables interactive staging.- Short aliases include
op log -n,undo -n,stashless -b/-k,metaedit date -a/-c,squash -f/--from -t/--to,diff -f/--from -t/--to, andmove -A/-B -f/--from -t/--to. - Command aliases include
reword r,edit e,squash s,fixup f,drop d, andmerge m.
Comparisons
| Tool | Focus | Link |
|---|---|---|
| git-surgeon | History helpers for commit rewriting/modifying | README.md |
| git-extras | Many Git helper commands | https://github.com/tj/git-extras |
| git-town | Branch workflow automation and syncing | https://www.git-town.com |
| jujutsu (jj) | Change-centric VCS with powerful history editing | https://github.com/jj-vcs/jj |
git surgeon is a namespaced subcommand (git surgeon ...), so its
subcommands do not collide with standalone git-* commands from other tools.
Compared to jj, git surgeon stays inside Git’s history model and wraps
interactive rebase, reflog, and merge flows. jj provides a change-centric DAG
with richer undo/redo semantics and native operations for moving, splitting,
and absorbing changes without the same history‑rewrite steps.
AI-assistance disclaimer
Portions of this project were created or refined with assistance from AI tools (spec. Codex). AI contributions were used for code generation, refactoring, architectural exploration, naming convention review, and documentation improvement, as well as for providing guidance on compiler issues.
All AI-generated or AI-assisted content has been reviewed, validated, and approved by me; the human developer responsible for this project, and someone I am reasonably confident is, in fact, human.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_surgeon-0.1.0.tar.gz.
File metadata
- Download URL: git_surgeon-0.1.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4a9ed3b9d9f802962541a7e6ec78633bec9b5a61450e78f1ef16edee5887c2a
|
|
| MD5 |
241fcc6340e650c14508bfdacac89146
|
|
| BLAKE2b-256 |
ed2157e4a3dcd062e9350de979dd7a1c5a6af00b71bc2a9a3d4fd510921d6c58
|
File details
Details for the file git_surgeon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: git_surgeon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8dd95a40408586cdb07a0acbdfab8245fa9ef50ba2915c5ad1e3a44bc72ac45
|
|
| MD5 |
d50040e2b61e7d47b5a428d9b725a686
|
|
| BLAKE2b-256 |
0ded7849d8c861ddd894c88e051e2b8a91c2a7282bb68b3bb63ee6191b4a4b73
|