AI-powered Git disaster recovery โ describe your git problem, get exact fix commands
Project description
๐ git-mistake
Describe your git disaster in plain English. Get exact fix commands instantly.
Why
Git has ~150 commands and error messages designed by a kernel hacker in 2005.
Every developer โ from interns to 10-year veterans โ eventually types the wrong
thing and freezes. git-mistake reads your actual repo state, understands what
went wrong, and tells you exactly what to run.
No Stack Overflow rabbit hole. No guessing. Just the fix.
Install
pip install git-mistake
Or run without installing:
pipx run git-mistake "your problem here"
Usage
# Describe your problem directly
git-mistake "I accidentally ran git reset --hard and lost my commits"
git-mistake "I committed to the wrong branch"
git-mistake "I have a merge conflict and I don't know how to resolve it"
git-mistake "I accidentally pushed my API key to GitHub"
git-mistake "I'm in a detached HEAD state"
# Interactive mode โ just run with no arguments
git-mistake
# Pattern matching only โ no AI, works fully offline
git-mistake --no-ai "I did git reset --hard"
# Dump your current git state (useful for bug reports)
git-mistake --context
How It Works
Your repo state Your problem description
โ โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Pattern Matcher โ โ Covers ~80% of cases instantly, offline
โโโโโโโโโโฌโโโโโโโโโโโโโ
โ No match?
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ AI Engine โ โ Handles complex/unusual situations
โโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โผ
Exact fix commands + explanation
Stage 1 โ Offline pattern matching reads your git reflog, git status,
and in-progress operation flags (merge, rebase, cherry-pick) to instantly
resolve common disasters without any API call.
Stage 2 โ AI fallback kicks in for complex or unusual situations. Supports 3 providers โ set whichever key you have.
Covered Scenarios
| Problem | Severity |
|---|---|
Accidental git reset --hard |
๐ด High |
| Pushed secrets / credentials | ๐ด High |
| Detached HEAD state | ๐ก Medium |
| Merge conflict stuck | ๐ก Medium |
| Rebase gone wrong | ๐ก Medium |
| Accidentally deleted tracked files | ๐ก Medium |
| Committed to wrong branch | ๐ข Low |
| Untracked files / .gitignore issues | ๐ข Low |
| Everything else | AI fallback |
AI Setup (Optional)
Works offline for common cases. For complex issues, set any one of these:
| Provider | Env Variable | Get Key | Free Tier |
|---|---|---|---|
| Anthropic Claude | ANTHROPIC_API_KEY |
console.anthropic.com | โ |
| OpenRouter | OPENROUTER_API_KEY |
openrouter.ai/keys | โ Yes |
| NVIDIA NIM | NVIDIA_API_KEY |
build.nvidia.com | โ Yes |
# Set whichever you have โ only one needed
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENROUTER_API_KEY="sk-or-..."
export NVIDIA_API_KEY="nvapi-..."
# Make it permanent
echo 'export OPENROUTER_API_KEY="sk-or-..."' >> ~/.zshrc
# Override the default model
export OPENROUTER_MODEL="google/gemma-3-27b-it"
export NVIDIA_MODEL="meta/llama-3.3-70b-instruct"
OpenRouter and NVIDIA NIM both have free tiers โ no credit card needed.
Architecture
git-mistake/
โโโ git_mistake/
โ โโโ cli.py # Entry point, argument parsing, orchestration
โ โโโ context.py # Reads all git state (reflog, status, flags)
โ โโโ detector.py # Fast offline pattern matching (~80% of cases)
โ โโโ ai_helper.py # Multi-provider AI fallback (Anthropic / OpenRouter / NVIDIA)
โ โโโ display.py # Terminal colors and formatted output
โโโ tests/
โ โโโ test_detector.py # 18 unit tests
โโโ .github/workflows/ci.yml
โโโ pyproject.toml
Design decisions:
- Zero dependencies โ stdlib only (
subprocess,urllib,json). No requests, no rich, no click. - Offline-first โ pattern matching runs before any API call is made.
- Context-aware โ reads actual
.git/state, not just your description. - Safe by default โ always suggests a backup branch before destructive commands.
Contributing
Bug reports with git-mistake --context output are incredibly useful.
PRs adding new patterns to detector.py are always welcome.
git clone https://github.com/thalha-a9/git-mistake
cd git-mistake
pip install -e .
python -m pytest tests/ -v
License
MIT โ see LICENSE
Built for every developer who has typed git reset and immediately regretted it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_mistake-1.0.1.tar.gz.
File metadata
- Download URL: git_mistake-1.0.1.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb3c5405c0e93deacd19da1df50d717808744b8181c19228d0f3b7d494c339da
|
|
| MD5 |
61569548b0ed106450a31a42b08cba71
|
|
| BLAKE2b-256 |
a733755a98af098b73ab38a2021d7a0ddbb7cf1c39fa35898ced125b6ada8926
|
Provenance
The following attestation bundles were made for git_mistake-1.0.1.tar.gz:
Publisher:
publish.yml on thalha-a9/git-mistake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_mistake-1.0.1.tar.gz -
Subject digest:
bb3c5405c0e93deacd19da1df50d717808744b8181c19228d0f3b7d494c339da - Sigstore transparency entry: 1656485679
- Sigstore integration time:
-
Permalink:
thalha-a9/git-mistake@5fb32d3263bc7325b5ef6a7b9323e89f6f52b52c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/thalha-a9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5fb32d3263bc7325b5ef6a7b9323e89f6f52b52c -
Trigger Event:
release
-
Statement type:
File details
Details for the file git_mistake-1.0.1-py3-none-any.whl.
File metadata
- Download URL: git_mistake-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb2e044c973ace0452e2837d1bf962d6c3a1751a146427fe30ef851ab267ff52
|
|
| MD5 |
e10e4559fac19de8dd581e674959c449
|
|
| BLAKE2b-256 |
4a53363f778b2c3e6c9cafb9a0f28d47fe7beb2a9ab0a195a685d6c0c9740025
|
Provenance
The following attestation bundles were made for git_mistake-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on thalha-a9/git-mistake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_mistake-1.0.1-py3-none-any.whl -
Subject digest:
cb2e044c973ace0452e2837d1bf962d6c3a1751a146427fe30ef851ab267ff52 - Sigstore transparency entry: 1656486093
- Sigstore integration time:
-
Permalink:
thalha-a9/git-mistake@5fb32d3263bc7325b5ef6a7b9323e89f6f52b52c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/thalha-a9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5fb32d3263bc7325b5ef6a7b9323e89f6f52b52c -
Trigger Event:
release
-
Statement type: