Documentation Index
Fetch the complete documentation index at: https://gx.mubbie.dev/llms.txt
Use this file to discover all available pages before exploring further.
gx undo inspects your repo state and automatically determines the right undo operation. It detects merges, rebases, staged files, amended commits, merge commits, and regular commits — then offers to reverse whichever it finds first.
gx redo reverses the last undo, restoring your repo to its previous state.
Usage
Flags
| Flag | Description |
|---|---|
--dry-run | Show what would be undone without making changes |
--history | Show the undo/redo history log |
Detection Priority
gx undo checks conditions in this order and acts on the first match:| Priority | Condition | Undo Action | Effect |
|---|---|---|---|
| 1 | Merge conflict in progress | git merge --abort | Returns to pre-merge state |
| 2 | Rebase in progress | git rebase --abort | Returns to pre-rebase state |
| 3 | Staged files present | git reset HEAD | Unstages all files, changes stay in working tree |
| 4 | Last reflog entry is amend | git reset --soft HEAD@{1} | Restores pre-amend state, changes preserved |
| 5 | Last reflog entry is merge commit | git reset --hard HEAD~1 | Removes the merge commit (hard reset) |
| 6 | Last reflog entry is commit | git reset --soft HEAD~1 | Soft reset, changes move back to staging |
Examples
Undo History
Every undo is recorded in.git/gx/undo_history.json. View recent history:
gx redo to safely restore the previous state.
Redo
gx redo reverses the most recent undo. It checks that the repo state has not changed since the undo was performed — if HEAD has moved, redo is blocked with an explanation.
Edge cases
Edge cases
- If nothing is detected, gx prints
> Nothing to undo. - History is capped at 50 entries and stored per-repo in
.git/gx/undo_history.json - Redo checks that HEAD matches the post-undo ref. If you made commits after undoing, redo will refuse with an explanation
- Redo blocks if the working tree is dirty to prevent data loss from
git reset --hard - Reflog detection skips non-matching entries instead of stopping at the first mismatch, improving detection accuracy
- Merge commit undo uses
--hardreset, which discards changes. Other undo types use--softreset