Skip to content

dinakars777/git-time-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ•ฐ๏ธ git-time-machine

Undo ANY git mistake in 3 seconds with a beautiful TUI

Never lose work again. git-time-machine makes git reflog visual, interactive, and actually usable.

โœจ The Problem

You just:

  • ๐Ÿ”ฅ Force pushed and lost commits
  • ๐Ÿ’ฅ Did git reset --hard by accident
  • ๐Ÿ—‘๏ธ Deleted a branch you needed
  • ๐Ÿคฆ Rebased wrong and broke everything
  • ๐Ÿ˜ฑ Can't remember what you did 5 minutes ago

Current solution: Dig through git reflog, copy cryptic hashes, pray you picked the right one.

Better solution: git-time-machine ๐ŸŽฏ

๐Ÿš€ Demo

Demo GIF

Navigate your git history like a time traveler. One key to restore.

๐Ÿ“ฆ Installation

Cargo (Recommended)

cargo install git-time-machine

From Source

git clone https://github.com/dinakars777/git-time-machine
cd git-time-machine
cargo install --path .

Homebrew (Coming Soon)

brew install git-time-machine

๐ŸŽฎ Usage

# Launch in any git repository
git-time-machine

# Show all reflog entries (default: last 50)
git-time-machine --all

Controls

Key Action
โ†‘ / k Move up
โ†“ / j Move down
Enter Restore to selected state
q / Esc Quit

๐ŸŽฏ Features

  • โœ… Visual Timeline - See your entire git history at a glance
  • โœ… Relative Timestamps - "5m ago", "2h ago", "yesterday"
  • โœ… One-Key Restore - Press Enter, done
  • โœ… Vim Keybindings - j/k navigation
  • โœ… Beautiful TUI - Built with Ratatui
  • โœ… Lightning Fast - Written in Rust
  • โœ… Zero Config - Just worksโ„ข

๐Ÿ”ฅ Use Cases

Scenario 1: "I Don't Know What I Did, But It's Broken"

# 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"
# Press Enter, back to working state โœจ

Why not git reflog? You'd need to:

  1. Read through cryptic hashes and messages
  2. Guess which one is "before you broke it"
  3. Manually git reset --hard <hash>
  4. Hope you picked the right one
  5. Repeat if wrong

Scenario 2: Recovering Lost Work After Complex Operations

# 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
# Press Enter to restore

Why not git reflog | grep? You'd need to:

  1. Know what to grep for
  2. Parse timestamps manually
  3. Cross-reference multiple entries
  4. Still guess which hash is correct

Scenario 3: Deleted Branch (Already Garbage Collected Locally)

# Deleted a branch 2 weeks ago
# Need it back but don't remember the commit hash
# git branch -D feature-branch was weeks ago

# With git-time-machine:
git-time-machine --all
# Scroll back through weeks of history
# Find "checkout: moving from feature-branch"
# See the commit hash right there
# Press Enter, then: git checkout -b feature-branch

Why not git reflog --all? You'd need to:

  1. Scroll through hundreds of lines of text
  2. Find the right branch name in the noise
  3. Extract the hash manually
  4. Remember the git commands to restore it

Scenario 4: "Undo" After You've Already Committed

# 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 Enter
# Cherry-pick the commits to the right branch

Why not git reset? You'd need to:

  1. Count how many commits back
  2. Remember if it's --soft, --mixed, or --hard
  3. Hope you counted right
  4. Manually re-apply commits if you messed up

๐Ÿ› ๏ธ How It Works

git-time-machine is a wrapper around git reflog that:

  1. Parses your reflog history
  2. Displays it in an interactive TUI
  3. Lets you preview and restore any state
  4. Executes git reset --hard <hash> when you press Enter

It's just git under the hood - no magic, no risk.

๐Ÿค” Why Not Just Use Git Commands?

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, press Enter
Recover deleted branch from 2 weeks ago git reflog --all | grep branch-name, find hash, git checkout -b, verify --all flag, scroll, press Enter
Undo complex operation sequence Remember exact commands, count commits, pick right reset flag Visual timeline, click the "before" state
Explore "what if" scenarios Multiple git reset attempts, risk losing more work Navigate freely, restore is one keypress

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 UI that doesn't require a PhD.

๐Ÿค Contributing

Contributions welcome!

Ideas for future versions:

  • Show file diffs inline
  • "Panic mode" - undo last N minutes
  • Branch visualization
  • Stash recovery
  • Search/filter commits
  • Export timeline as JSON

๐Ÿ“ License

MIT ยฉ Dinakar Sarbada

๐ŸŒŸ Star History

If this saved you once, give it a star! โญ


Made with โค๏ธ and Rust | Report Bug | Request Feature