Quick recovery from common git mistakes including undo commits, recover branches, and reflog operations. Use when you need to undo, recover, or fix Git history.
View on GitHubyonatangross/skillforge-claude-plugin
ork
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/yonatangross/skillforge-claude-plugin/blob/main/skills/git-recovery-command/SKILL.md -a claude-code --skill git-recovery-commandInstallation paths:
.claude/skills/git-recovery-command/# Git Recovery Interactive recovery from common git mistakes. Safe operations with verification steps. ## Quick Start ```bash /git-recovery ``` ## Recovery Scenarios When invoked, present these options to the user: ### Option 1: Undo Last Commit (Keep Changes) **Scenario**: You committed but want to modify the changes before recommitting. ```bash # Check current state first git log --oneline -3 git status # Undo commit, keep changes staged git reset --soft HEAD~1 # Verify git status # Changes should be staged git log --oneline -1 # Previous commit is now HEAD ``` **Safety**: Non-destructive. All changes remain staged. --- ### Option 2: Undo Last Commit (Discard Changes) **Scenario**: You committed something completely wrong and want to throw it away. **WARNING: DESTRUCTIVE - Changes will be lost!** ```bash # CRITICAL: First, save a backup reference BACKUP_REF=$(git rev-parse HEAD) echo "Backup ref: $BACKUP_REF (save this to recover if needed)" # Show what will be lost git show HEAD --stat # Confirm with user before proceeding # Then execute: git reset --hard HEAD~1 # Verify git log --oneline -3 git status # Should be clean ``` **Recovery**: If you made a mistake, run `git reset --hard $BACKUP_REF` --- ### Option 3: Recover Deleted Branch **Scenario**: You deleted a branch and need it back. ```bash # Find the branch's last commit in reflog git reflog | grep -i "branch-name" # Or search all recent activity: git reflog --all | head -30 # Once you find the commit hash (e.g., abc1234): git checkout -b recovered-branch abc1234 # Verify git log --oneline -5 git branch -v | grep recovered ``` **Note**: Reflog keeps entries for ~90 days by default. --- ### Option 4: Reset File to Last Commit **Scenario**: You modified a file and want to discard local changes. **WARNING: DESTRUCTIVE - Uncommitted changes to file will be lost!** ```bash # Show current changes to file git diff path/to/file # Confirm with user before proceeding # Then restore: