npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gitpanic

v1.0.0

Published

Interactive CLI that diagnoses git mistakes and guides you through recovery

Downloads

171

Readme

gitpanic

Interactive CLI that diagnoses git mistakes and guides you through recovery — like git reflog but human-friendly.

Why gitpanic?

Every developer has panicked after a bad git operation. Stack Overflow's top git questions are all "how do I undo...":

  • "How to undo last commit" — 16k+ upvotes
  • "How to undo git push" — 5k+ upvotes
  • "How to recover deleted branch" — 3k+ upvotes
  • "How to undo git merge" — 2k+ upvotes

git reflog is powerful but intimidating. gitpanic provides an interactive wizard that:

  1. Auto-detects common git disasters from your repository state
  2. Diagnoses the problem in plain English
  3. Guides you through recovery with risk levels and confirmations
  4. Protects you by never executing without confirmation

Installation

npm install -g gitpanic

Or use with npx:

npx gitpanic

Usage

Basic Scan

Run gitpanic in any git repository:

$ gitpanic
🔍 Analyzing your git state...

⚠️  Found 1 potential issue:

1. 🟢 Uncommitted Changes
   You have 3 uncommitted files. 1 staged. 2 modified.
   Confidence: 100%

Select an issue to fix [1-1] or press Enter to exit: 1

🔧 Recovery options for: Uncommitted Changes

1. ✅ Stash changes
   Save your changes to apply later
   Risk: safe
   Steps:
   - git stash push -m "WIP"

2. ✅ Commit changes
   Create a commit with your changes
   Risk: safe
   Steps:
   - git add .
   - git commit -m "WIP"

3. ⚠️ Discard all changes
   Remove all uncommitted changes (DANGEROUS)
   Risk: high
   Steps:
   - git reset --hard HEAD
   - git clean -fd

Select a recovery option [1-3]: 1
⚠️  Confirm: "Stash changes"? This can be undone. [y/N]: y

🚀 Executing recovery...

✅ Recovery complete!

Dry Run Mode

Preview what would happen without making changes:

gitpanic --dry-run

Non-Interactive Mode

For use in scripts (requires manual implementation of recovery options):

gitpanic --non-interactive

Detected Disasters

gitpanic can detect and recover from:

| Disaster | Description | Severity | |----------|-------------|----------| | Detached HEAD | You're in detached HEAD state | Medium | | Deleted Branch | A branch was recently deleted | High | | Force Push | You recently force-pushed (may have overwritten commits) | High | | Botched Merge | Merge in progress or recently aborted | Medium | | Accidental Commit | Recent commit that might be a mistake | Low | | Uncommitted Changes | Files that need to be committed | Low | | Wrong Branch Commit | Commit that might belong on main/master | Medium |

Recovery Options

Each disaster comes with multiple recovery strategies with different risk levels:

  • Safe: Can be easily undone (e.g., stash, soft reset)
  • Medium: May require manual intervention (e.g., cherry-pick)
  • ⚠️ High: Destructive, cannot be undone (e.g., hard reset, clean)

How It Works

  1. Analysis Phase: gitpanic analyzes your git state using:

    • git reflog to find recent operations
    • git status to check for uncommitted changes
    • git log to examine commit history
  2. Detection Phase: Multiple detectors scan for patterns:

    • Recent commits (< 2 minutes) → accidental commit?
    • Detached HEAD state → need to reattach?
    • Force push in reflog → overwritten commits?
    • Branch deletion in reflog → can be recovered?
    • MERGE_HEAD file → merge conflict?
    • Untracked/modified files → need to commit?
  3. Recovery Phase: For each detected disaster, provide:

    • Clear explanation of what happened
    • Multiple recovery options with risk levels
    • Step-by-step command preview
    • Confirmation before execution

Examples

Recover a Deleted Branch

$ gitpanic
⚠️  Found 1 potential issue:

1. 🔴 Deleted Branch
   Branch "feature/login" was deleted 45 seconds ago.
   Confidence: 90%

Select an issue to fix [1-1]: 1

🔧 Recovery options for: Deleted Branch

1. ✅ Restore branch "feature/login"
   Recreate the branch from the deleted commit
   Risk: safe
   Steps:
   - git branch feature/login abc1234
   - git checkout feature/login

Select a recovery option [1-1]: 1
⚠️  Confirm: "Restore branch \"feature/login\""? This can be undone. [y/N]: y

✅ Recovery complete!

Undo an Accidental Commit

$ gitpanic
⚠️  Found 1 potential issue:

1. 🟢 Accidental Commit
   You just committed "typo fix" 12 seconds ago.
   Confidence: 80%

Select an issue to fix [1-1]: 1

🔧 Recovery options for: Accidental Commit

1. ✅ Undo commit, keep changes staged
   Remove the commit but keep your changes ready to commit
   Risk: safe
   Steps:
   - git reset --soft HEAD~1

Select a recovery option [1-1]: 1
⚠️  Confirm: "Undo commit, keep changes staged"? This can be undone. [y/N]: y

✅ Recovery complete!

Fix Detached HEAD

$ gitpanic
⚠️  Found 1 potential issue:

1. 🟡 Detached HEAD
   You are in detached HEAD state. Changes here can be lost.
   Confidence: 100%

Select an issue to fix [1-1]: 1

🔧 Recovery options for: Detached HEAD

1. ✅ Reattach to previous branch
   Switch back to main
   Risk: safe
   Steps:
   - git checkout main

Select a recovery option [1-1]: 1
⚠️  Confirm: "Reattach to previous branch"? This can be undone. [y/N]: y

✅ Recovery complete!

Development

# Clone
git clone https://github.com/sulthonzh/gitpanic.git
cd gitpanic

# Install
npm install

# Build
npm run build

# Test
npm test

# Run local
node dist/cli.js

License

MIT

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

Similar Tools

What makes gitpanic different?

  • Interactive wizard UI (not just commands)
  • Auto-detects problems (no manual diagnosis needed)
  • TypeScript (modern, type-safe)
  • Recovery preview with risk levels
  • Safety-first with confirmations