plugins/developer-toolkit/skills/git/git-undo-wizard/SKILL.md
Use this skill when the user needs to undo, revert, or recover from Git mistakes. Activate when they mention: undo commit, revert changes, accidentally committed, wrong branch, recover deleted, reset HEAD, undo push, undo merge, restore file, git reflog, "I messed up", lost commits, or any Git recovery scenario.
npx skillsauth add latestaiagents/agent-skills git-undo-wizardInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Recover from any Git mistake safely.
| Situation | Command |
|-----------|---------|
| Undo last commit, keep changes | git reset --soft HEAD~1 |
| Undo last commit, discard changes | git reset --hard HEAD~1 |
| Undo changes to a file | git checkout -- <file> |
| Undo staged changes | git reset HEAD <file> |
| Undo a pushed commit | git revert <commit> |
| Recover deleted branch | git reflog + git checkout -b <branch> <sha> |
Keep the changes (just uncommit):
git reset --soft HEAD~1
# Changes are now staged, ready to recommit
Unstage the changes too:
git reset HEAD~1
# Changes are in working directory, not staged
Discard everything (dangerous):
git reset --hard HEAD~1
# Changes are gone forever
Safe way (creates a new "undo" commit):
git revert HEAD
git push
# This creates a new commit that undoes the previous one
If you MUST rewrite history (only on your own branch):
git reset --hard HEAD~1
git push --force-with-lease
# Never do this on shared branches!
Move commit to correct branch:
# Note the commit hash
git log -1 # Copy the hash
# Go to correct branch
git checkout correct-branch
# Cherry-pick the commit
git cherry-pick <commit-hash>
# Go back and remove from wrong branch
git checkout wrong-branch
git reset --hard HEAD~1
Discard unstaged changes:
git checkout -- <filename>
# Or in newer Git:
git restore <filename>
Unstage a file (keep changes):
git reset HEAD <filename>
# Or in newer Git:
git restore --staged <filename>
Restore file to specific commit:
git checkout <commit-hash> -- <filename>
# Find the last commit of deleted branch
git reflog
# Look for entries like "checkout: moving from deleted-branch to main"
# Note the SHA before deletion
# Recreate the branch
git checkout -b recovered-branch <sha>
# Git reflog shows ALL recent HEAD movements
git reflog
# Find your lost commit
# Example output:
# abc1234 HEAD@{0}: reset: moving to HEAD~3
# def5678 HEAD@{1}: commit: Important work <-- This one!
# Recover it
git checkout -b recovery-branch def5678
# Or cherry-pick it
git cherry-pick def5678
If not pushed:
git reset --hard HEAD~1
# Or to specific commit before merge:
git reset --hard <commit-before-merge>
If already pushed:
git revert -m 1 <merge-commit-hash>
git push
If not pushed:
# Remove from last commit
git reset --soft HEAD~1
# Remove sensitive file
git rm --cached <sensitive-file>
# Add to .gitignore
echo "sensitive-file" >> .gitignore
# Recommit
git add .
git commit -m "Remove sensitive data"
If already pushed (requires rewriting history):
# Use git-filter-repo (install first)
git filter-repo --path <sensitive-file> --invert-paths
# Force push all branches (coordinate with team!)
git push --force --all
# Unstage everything
git reset
# Unstage specific file
git reset HEAD <file>
# Keep file staged but undo modifications
git checkout HEAD -- <file>
# Discard ALL local changes and commits
git fetch origin
git reset --hard origin/main
# Or clean untracked files too
git clean -fd
Git reflog is your time machine. It tracks every HEAD movement for ~90 days.
# See recent history
git reflog
# See with timestamps
git reflog --date=relative
# Recover ANY previous state
git reset --hard HEAD@{5} # Go back 5 operations
Before dangerous operations:
git stash # Save work in progress
# or
git branch backup-branch # Create safety branch
Use --force-with-lease instead of --force:
git push --force-with-lease # Fails if remote changed
Check before reset:
git log --oneline -10 # See what you're about to affect
--force on shared branchesreset --hard without checking git stash listreflog is local onlydevelopment
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.