git-rescue
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
Metadata
Release files for git-rescue-cli 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| git_rescue_cli-0.1.2.tar.gz | 15.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| git_rescue_cli-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.6 kB
Release files / git_rescue_cli-0.1.2.tar.gz
| Download URL | git_rescue_cli-0.1.2.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63fb86f9f134696dd0f291b3cb8eeb1a07cf63ca5f03155e493d751b97d448cf
|
|
BLAKE2b-256 checksum How to use checksums |
09c5938dab7fe039bdc51252ba2a49f01c4e4d0714d321d40276851df9f7c2aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / git_rescue_cli-0.1.2-py3-none-any.whl
| Download URL | git_rescue_cli-0.1.2-py3-none-any.whl |
|---|---|
| Size | 18.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9dd31b434208da1e2836ea241b2f403257fc959d525fb4dc6036d35fbbf0bba
|
|
BLAKE2b-256 checksum How to use checksums |
369066c468f6ff11485460717f7a8c5c5c68462891988c653e0a76dda3e300db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|