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.1.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.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_rescue_cli-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c0cfc29aff01f2ed114c2dde9ee6ac9b41609f585842fb4826c83eaecc87d1fd
MD5 03861a0c05bfb3d991897b0f09fc3c79
BLAKE2b-256 533619fd6081c0e92f5575d899048a744b51ec4dd8c513a206e10e1831bf3a66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: git_rescue_cli-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d17b346c262c482b0c5251a28a6b6e0d300246b8577e93f9d2d6659e3953dadc
MD5 32b2110da523c415e6f6b217e559c7e9
BLAKE2b-256 b1e48a4a6980f97894436fba4090691031d333c34cc104b6c8cdf701b84310c6

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

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