git-undo
Undo previous Git operations
TLDR
Remove the most recent commit
Remove a specific number of the most recent commits
SYNOPSIS
git undo [days] [--grep=TEXT] [--clear] [--install] [--uninstall] [--raw]
PARAMETERS
days
Days back to scan history (default: 7)
-g, --grep TEXT
Filter history by commands containing TEXT
--clear
Clear undo history cache
--install
Install Git pre-commit hook for logging
--uninstall
Remove Git hook
--raw
Output raw history without interactive menu
-h, --help
Show help
--version
Print version
DESCRIPTION
git undo is a powerful third-party Git extension designed to simplify undoing recent Git operations. Unlike built-in Git commands like git reset or git revert, it maintains a history of executed Git commands (via a pre-commit hook) and presents an interactive menu for selecting which one to undo.
It scans the Git reflog and command log (stored in ~/.cache/git-undo) for the last n days (default 7), filters if needed, and generates precise undo instructions, such as git reset, git clean, or git checkout. Users select via arrow keys or numbers, then execute the suggested command.
Ideal for quick recovery from mistakes like accidental commits, merges, or rebases without deep reflog knowledge. Install via cargo install git-undo, Homebrew (brew install git-undo), or binaries. Requires installing the Git hook with git undo --install for command logging.
CAVEATS
Not a core Git command; requires separate installation.
Hook must be installed for full command history.
Undos are suggestions—review before executing.
May not handle all complex operations perfectly.
INSTALLATION
cargo install git-undo
or brew install git-undo
Then git undo --install.
STORAGE
History in ~/.cache/git-undo/; respects XDG_CACHE_HOME.
HISTORY
Developed by @ibigbug, first released in 2020 as a Rust crate on GitHub (git-undo/git-undo). Gained popularity for user-friendly interface, with updates adding raw output and better filtering. Installed via Cargo, Homebrew, or AUR.
SEE ALSO
git reflog(1), git reset(1), git revert(1), git restore(1), git clean(1)


