Skip to main content

git-rescue

CI Passing PyPI version Python 3.8+ License: MIT Zero Dependencies

Zero-dependency Git disaster recovery. Parses reflog and dangling objects into human-readable action cards with safe, 1-click restore.


The Problem

Accidental git reset --hard, deleted branches, or aborted rebases leave orphaned commits and lost work. While Git preserves these in the reflog and loose object databases, manual recovery commands are low-level and error-prone:

# Manual recovery:
git reflog | head -20
git fsck --lost-found --no-reflogs
git cat-file -p abc1234
git reset --hard HEAD@{3}

The Solution

pip install git-rescue-cli
# Recovery with git-rescue:
git-rescue                    # Inspect timeline and recent actions
git-rescue undo               # Revert the last destructive operation
git-rescue branches           # Find and restore deleted branches
git-rescue files              # Recover lost staged files

Quick Start

Installation

pip install git-rescue-cli

Or install from source:

git clone https://github.com/omdesai69/git-rescue.git
cd git-rescue
pip install -e .

Requirements

  • Python 3.8+
  • Git 2.10+ (available on PATH)
  • Zero external dependencies (standard library only)

Commands

git-rescue / git-rescue timeline

Scans reflog entries and displays a structured timeline:

  +--------------------------------------+
  |         git-rescue v0.1.0            |
  |     Zero-dependency Git recovery     |
  +--------------------------------------+

  * [0] a1b2c3d4  Commit: Fix authentication bug
    2024-06-15 14:32:00 +0530
  |
  > [1] d4e5f6a7  Hard Reset -> HEAD~2
    2024-06-15 14:30:00 +0530
  |
  * [2] f6a7b8c9  Commit: Add user dashboard
    2024-06-15 14:25:00 +0530

  1 destructive operation detected. Run `git-rescue undo` to recover.

Control displayed entry count:

git-rescue timeline -n 50

git-rescue undo

Identifies the latest destructive operation and safely restores pre-operation state:

  Backup created: refs/rescue/backup-1718448600

  +------------------------------------------+
  | Recovery Complete                        |
  | Reverted: Hard Reset -> HEAD~2           |
  |                                          |
  |   Restored to: a1b2c3d4e5f6              |
  |   Backup ref:  refs/rescue/backup-...    |
  |                                          |
  |   Changes recovered:                     |
  |     dashboard.py | 45 +++++++++          |
  |     auth.py      | 12 +++               |
  +------------------------------------------+

  To revert this operation: git reset --hard refs/rescue/backup-1718448600

git-rescue branches

Scans reflog for branch references and provides restoration:

git-rescue branches                        # List deleted branches
git-rescue branches --restore feature-x    # Restore specific branch

git-rescue files

Recovers dangling blobs (lost staged files) from git fsck:

git-rescue files

Recovered files are written to .git/rescue-recovered/ alongside JSON metadata sidecars.


Safety Guarantees

Before executing any state-modifying action, git-rescue automatically creates an immutable timestamped backup ref:

refs/rescue/backup-<timestamp>
  • Pre-rescue state is fully preserved.
  • Undo operations are reversible: git reset --hard refs/rescue/backup-<timestamp>.
  • Backup refs are explicit Git references protected from automatic garbage collection.

Global Options

Flag Description
--no-color Disable ANSI color formatting
--version Display version information
-n, --limit Maximum entries to display (timeline)

The NO_COLOR environment variable is fully supported.


Development

git clone https://github.com/omdesai69/git-rescue.git
cd git-rescue
pip install -e ".[dev]"
pytest

License

MIT - see LICENSE.

Copyright (c) 2026 Om Desai

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_rescue_cli-0.1.2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_rescue_cli-0.1.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file git_rescue_cli-0.1.2.tar.gz.

File metadata

  • Download URL: git_rescue_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for git_rescue_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 63fb86f9f134696dd0f291b3cb8eeb1a07cf63ca5f03155e493d751b97d448cf
MD5 7ce9c32f146ab3fad24c954009bc8774
BLAKE2b-256 09c5938dab7fe039bdc51252ba2a49f01c4e4d0714d321d40276851df9f7c2aa

See more details on using hashes here.

File details

Details for the file git_rescue_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: git_rescue_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for git_rescue_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e9dd31b434208da1e2836ea241b2f403257fc959d525fb4dc6036d35fbbf0bba
MD5 798d00ea21b4cd4cfd3441952d487dba
BLAKE2b-256 369066c468f6ff11485460717f7a8c5c5c68462891988c653e0a76dda3e300db

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page