Browse Git reflog visually and recover reachable local history with a TUI
git-time-machine makes git reflog visual and interactive.
You just:
- ๐ฅ Moved HEAD and need to find the previous state
- ๐๏ธ Deleted a local branch and need the last reachable commit
- ๐คฆ Ran several Git operations and cannot remember the sequence
- ๐ฑ Need to inspect what changed before choosing a recovery point
Current solution: Read through git reflog, copy hashes, compare candidates, and run the right Git command manually.
Better: git-time-machine ๐ฏ
Navigate your local reflog, preview changes, and restore deliberately.
cargo install git-time-machinegit clone https://github.com/dinakars777/git-time-machine
cd git-time-machine
cargo install --path .# Launch in any git repository
git-time-machine
# Show up to 1000 reflog entries (default: last 50)
git-time-machine --all
# Export the current reflog view as JSON
git-time-machine --export-json
# List hard-reset backup refs and recovery commands
git-time-machine --list-backups| Key | Action |
|---|---|
โ / k |
Move up |
โ / j |
Move down |
Home / End |
Jump to first/last entry |
gg / G |
Jump to first/last entry (vim-style) |
PgUp / PgDn |
Jump 10 entries |
Space |
Toggle diff panel |
d |
Switch between diff summary and full diff |
t |
Toggle relative/absolute timestamps |
/ |
Search/filter commits by message |
Esc |
Clear active filter, or quit if no filter is active |
Enter |
Hard reset to selected state after creating a backup ref |
s |
Soft reset to selected state |
c |
Checkout selected state in detached HEAD |
q |
Quit |
- โ Visual Timeline - See recent reflog entries at a glance
- โ Relative Timestamps - "5m ago", "2h ago", "yesterday"
- โ Diff Preview - Compare the selected entry before restoring
- โ Safer Restore Modes - Choose hard reset, soft reset, or detached checkout
- โ Backup Ref Recovery - List backup refs and exact recovery commands
- โ Search/Filter - Filter commit messages with multi-word search
- โ JSON Export - Export the reflog timeline for automation
- โ Vim Keybindings - j/k and gg/G navigation
- โ Beautiful TUI - Built with Ratatui
- โ Lightning Fast - Written in Rust
- โ Zero Config - Just works
# You ran a bunch of git commands, something broke
# You don't remember the exact sequence
# git reflog shows 50+ cryptic entries
# With git-time-machine:
git-time-machine
# Visually scan the timeline
# See "2h ago - before I started messing around"
# Preview the diff, then choose Enter, s, or c if it is the right stateWhy not git reflog? You'd need to:
- Read through cryptic hashes and messages
- Guess which one is "before you broke it"
- Manually
git reset --hard <hash> - Hope you picked the right one
- Repeat if wrong
# You did: rebase, merge, reset, amend, rebase again
# Now you need code from 3 operations ago
# But you don't remember the exact hash
# With git-time-machine:
git-time-machine
# Scroll through visual timeline
# See relative timestamps: "15m ago", "1h ago"
# Find the state you need
# Preview the diff, then pick hard reset, soft reset, or detached checkoutWhy not git reflog | grep? You'd need to:
- Know what to grep for
- Parse timestamps manually
- Cross-reference multiple entries
- Still guess which hash is correct
# Deleted a branch recently but forgot the commit hash
# git branch -D feature-branch
# With git-time-machine:
git-time-machine --all
# Scroll back through your history
# Find "checkout: moving from feature-branch"
# Copy the short hash displayed in the UI
# Hit 'q' to exit, then run: git branch feature-branch <hash>Why not git reflog --all? You'd need to:
- Scroll through hundreds of lines of text
- Find the right branch name in the noise
- Extract the hash manually
- Remember the git commands to restore it
# You committed to the wrong branch
# Then made 3 more commits
# Then realized the mistake
# git revert won't help - you need to go back in time
# With git-time-machine:
git-time-machine
# Find "before I committed to wrong branch"
# Press c to checkout that state safely
# Cherry-pick the commits to the right branchWhy not git reset? You'd need to:
- Count how many commits back
- Remember if it's
--soft,--mixed, or--hard - Hope you counted right
- Manually re-apply commits if you messed up
git-time-machine is a reflog browser. It can only help with history that Git can still see locally.
| Situation | Can it help? | Notes |
|---|---|---|
You moved HEAD with reset, rebase, merge, amend, or checkout |
Usually | If the target commit is still in the local reflog, you can inspect and restore it. |
| You deleted a local branch | Usually | If the branch tip is still reachable from your local reflog, you can find the commit hash and recreate the branch manually. |
| You force-pushed a remote branch | Sometimes | Only if the commits existed in your local clone before the force-push. It cannot recover commits that were never fetched locally. |
| You lost uncommitted, unstashed files | No | Git reflog tracks refs, not arbitrary working-tree file contents. |
| Git garbage-collected the commit | No | If Git has permanently removed the object, this tool cannot bring it back. |
git-time-machine is a wrapper around git reflog that:
- Parses your reflog history
- Displays it in an interactive TUI
- Lets you preview and restore reachable local states
- Shows the exact Git command before restore
- Runs one of:
git reset --hard <hash>,git reset --soft <hash>, orgit checkout <hash>(detached HEAD)
It's just Git under the hood - useful, but not magic. Hard reset is destructive, so git-time-machine creates a backup ref under refs/git-time-machine/backups/ before running it.
To find those backup refs later:
git-time-machine --list-backupsThe command prints each backup ref, the commit it points to, and exact git show
and git reset --hard commands for manual inspection and recovery.
You absolutely can! But here's the reality:
| Task | With git commands | With git-time-machine |
|---|---|---|
| Find state from "before I broke it" | git reflog, scan 50+ lines, guess hash, git reset --hard <hash>, hope it's right |
Scroll, preview, confirm |
| Recover a deleted branch's commit hash | git reflog, search manually, find hash, git checkout -b, verify |
Expanded reflog view, scroll, copy hash |
| Undo complex operation sequence | Remember exact commands, count commits, pick right reset flag | Visual timeline, select the "before" state |
| Explore "what if" scenarios | Multiple git reset attempts, risk losing more work |
Navigate, preview, and confirm from one interface |
git-time-machine doesn't replace git - it makes reflog actually usable for humans who:
- Don't memorize commit hashes
- Don't want to grep through 200 lines of text
- Want to see their history visually
- Need to undo mistakes quickly without googling
Think of it as git reflog with a visual interface for recovery decisions.
Contributions welcome!
See ROADMAP.md for the focused feature plan, recovery boundaries, and explicit non-goals.
Next ideas under active consideration:
- Mixed reset mode
- "Panic mode" - undo last N minutes
- Branch visualization
- Stash recovery
- Copy selected commit hash to clipboard
- True all-ref reflog mode for deleted branch recovery
MIT ยฉ Dinakar Sarbada
If this saved you once, give it a star! โญ
Made with โค๏ธ and Rust | Report Bug | Request Feature
