undo
Skill2 starsChanged 21 days agoMITView on GitHub
Parent Skill: /git Path: /git/undo Trigger automatically when: - User mentions: undo, reset, revert, restore, reflog, recover, amend, rollback - Made mistake in commit - Need to unstage files - Want to discard changes - Recover deleted commits - Fix commit history Chat commands: Problem: Staged file by mistake Before and after: Old vs new syntax: Impact: Remove file from staging without losing changes When to use: - Staged wrong file - Want to commit files separately - Accidentally staged…
- Reads credentials
- Deletes or force-pushes
- Commits and pushes
7 other projects use a version of this.
Adopted by
Most recently taken up by
- laz3rjenkins/atomic-commitstheir own version, first seen Nov 8, 2026
- buildomator/buildomatortheir own version, first seen Nov 4, 2026
- MFaizR77/turnbacktheir own version, first seen Oct 14, 2026
- manastalukdar/ai-devstudiotheir own version, first seen Oct 13, 2026
- kks0488/vibe-claudetheir own version, first seen Oct 11, 2026
- hailneed/agent-blackboxtheir own version, first seen Aug 19, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- buildomator/buildomator★ 102same name
- kks0488/vibe-claude★ 29same name
- hereinthehive/kickstart★ 4same name
- manastalukdar/ai-devstudio★ 1same name
- MFaizR77/turnback★ 1same name
- hailneed/agent-blackbox★ 0same name
- laz3rjenkins/atomic-commits★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- skills/react-best-practices/AGENTS.mdAGENTS.md
- skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- check-seoSkill
- brainstormingSkill
- check-seoSkill
- code-reviewerSkill
- create-a-skillSkill
- dispatching-parallel-agentsSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- frontend-designSkill
- advancedSkill
- basicsSkill
- branchingSkill
- conflictsSkill
- historySkill
- remoteSkill
- gitSkill
- workflowsSkill
- vercel-react-best-practicesSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- senior-backendSkill
- senior-frontendSkill
- senior-fullstackSkill
- senior-qaSkill
- skill-creatorSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- test-fullySkill
- using-git-worktreesSkill
- using-screenkitSkill
- vercel-composition-patternsSkill
- verification-before-completionSkill
- webapp-testingSkill
- web-crawlerSkill
- writing-plansSkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 14 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
14
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 54
NEVER use git reset --hard without backup if unsure
- Distinctive: line 55
NEVER force push reset to shared branches
- Distinctive: line 56
ALWAYS verify what will be affected before undo
- Distinctive: line 57
Use git revert for public history (not reset)
- Distinctive: line 58
ALWAYS check git status before major undo operations
- Distinctive: line 130
Impact: Remove file from staging without losing changes
- Distinctive: line 142
Problem: Don't want local modifications
- Distinctive: line 278
After pushing own branch (with force-with-lease)
- Distinctive: line 365
Start over from specific point (hard)
- Distinctive: line 366
Never on public branches!
- Distinctive: line 744
Check status first: - Always git status before major undo
- Distinctive: line 745
Prefer revert for public: - Use revert on shared branches
- Distinctive: line 746
Reset for private only: - Only reset on your own branches
- Distinctive: line 747
Backup before hard reset: - Create branch or stash
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Undo
Parent Skill: /git
Path: /git/undo
Purpose
Master undoing changes at every stage: unstage files, discard working changes, amend commits, reset history, revert safely, and recover lost commits with reflog.
When to Use
Trigger automatically when:
- User mentions: undo, reset, revert, restore, reflog, recover, amend, rollback
- Made mistake in commit
- Need to unstage files
- Want to discard changes
- Recover deleted commits
- Fix commit history
Chat commands:
/git/undo unstage this file
/git/undo discard my local changes
/git/undo fix my last commit message
/git/undo undo last commit but keep changes
/git/undo recover deleted commitRequirements
<critical>
- Git repository with commit history (for most operations)
- Understanding of Git states (working/staging/committed)
- For recovery: Commits not garbage collected yet
- CAUTION: Some operations destructive and irreversible
</critical>Verification
# Check current state
git status
# See commit history
git log --oneline -5
# Check reflog (for recovery)
git reflogCritical Rules
<critical>
1. NEVER use `git reset --hard` without backup if unsure
2. NEVER force push reset to shared branches
3. ALWAYS verify what will be affected before undo
4. Use `git revert` for public history (not reset)
5. ALWAYS check `git status` before major undo operations
6. Reflog expires after 90 days - recover deleted commits ASAP
</critical>Undo Workflow
File States & Undo Commands:
Working Directory → Staging → Repository
(modified) (staged) (committed)
↓ ↓ ↓
git restore git restore git reset
--staged or git revert
Recovery: git reflog (for any deleted commits)Patterns
Pattern 1: Unstage Files (Restore --staged)
Problem: Staged file by mistake
# ❌ BAD: Old confusing syntax
git reset HEAD file.js # Works but unclear
# ✅ GOOD: Modern, clear syntax (Git 2.23+)
git restore --staged file.js
# Unstage all files
git restore --staged .
# Unstage specific files
git restore --staged src/app.js src/utils.jsBefore and after:
# Accidentally staged everything
git add .
git status
# Changes to be committed:
# modified: src/app.js
# modified: .env # Oops! Secret file!
# Unstage .env
git restore --staged .env
git status
# Changes to be committed:
# modified: src/app.js
# Changes not staged:
# modified: .env # Back to unstagedOld vs new syntax:
# Old way (still works)
git reset HEAD file.js
# New way (clearer intent)
git restore --staged file.js
# Both do same thing: unstage fileImpact: Remove file from staging without losing changes
When to use:
- Staged wrong file
- Want to commit files separately
- Accidentally staged secrets
- Reviewing what to commit
Pattern 2: Discard Working Directory Changes (Restore)
Problem: Don't want local modifications
# ❌ DANGEROUS: Old confusing syntax
git checkout -- file.js # Confusing with branch checkout
# ✅ GOOD: Modern, clear syntax
git restore file.js
# Discard all changes
git restore .
# Discard specific files
git restore src/app.js src/utils.js
# Interactive discard (choose hunks)
git restore -p file.jsWarning - This is destructive!
# Before restore
git status
# Changes not staged for commit:
# modified: src/app.js # Hours of work!
# ❌ DANGER: Lost forever if not staged!
git restore src/app.js
# After restore: changes gone!
git status
# nothing to commit, working tree clean
# CANNOT UNDO THIS! Changes lost!Safe workflow:
# Save changes first (just in case)
git stash
# Or commit to temporary branch
git checkout -b backup-$(date +%Y%m%d-%H%M%S)
git add .
git commit -m "Backup before restore"
git checkout original-branch
# Then restore if still needed
git restore file.jsRestore from specific commit:
# Restore file from specific commit
git restore --source=abc1234 file.js
# Restore from main branch
git restore --source=main file.js
# Restore file to staged state
git restore --staged --worktree file.jsImpact: Clean working directory, but changes lost
When to use:
- Experimental changes failed
- Want to start over
- Undo local edits
- Match repository state
Pattern 3: Amend Last Commit
Problem: Typo in commit message or forgot to include file
# ❌ BAD: Create new commit for minor fix
git commit -m "Add user authentification" # Typo!
git commit -m "Fix typo in commit message" # Messy history
# ✅ GOOD: Amend last commit
git commit -m "Add user authentification" # Typo!
# Fix: Amend instead
git commit --amend -m "Add user authentication"Forgot to include file:
# Made commit
git commit -m "Add user authentication"
# Oops, forgot a file!
git add src/forgot-this.js
# Add to last commit
git commit --amend --no-edit
# --no-edit keeps same messageChange last commit message:
# Change message interactively
git commit --amend
# Editor opens, change message, save
# Change message inline
git commit --amend -m "New commit message"After amend:
# If already pushed (careful!)
git push --force-with-lease origin feature-branch
# If NOT pushed yet:
git push -u origin feature-branchAmend author:
# Change last commit author
git commit --amend --author="Name <email@example.com>"
# Use configured user
git commit --amend --reset-authorImpact: Clean up last commit without extra commits
When to use:
- Typo in commit message
- Forgot to include file
- Wrong author
- Before pushing (safe)
- After pushing own branch (with force-with-lease)
Pattern 4: Reset (Soft, Mixed, Hard)
Problem: Undo commits with different levels
# Three types of reset:
# --soft: Undo commit, keep staged
# --mixed: Undo commit, unstage (default)
# --hard: Undo commit, discard changesSoft reset (keep changes staged):
# Undo last commit, keep changes in staging
git reset --soft HEAD~1
# Before:
# Commit: abc1234 "Add feature"
# Status: Working directory clean
# After:
# Commit: def5678 (previous commit)
# Status: All changes from abc1234 are staged
# Use case: Redo commit with different message
git reset --soft HEAD~1
git commit -m "Better commit message"Mixed reset (unstage changes):
# Undo last commit, unstage changes (default)
git reset HEAD~1
# Same as:
git reset --mixed HEAD~1
# Before:
# Commit: abc1234 "Add feature"
# After:
# Commit: def5678
# Status: Changes from abc1234 are unstaged
# Use case: Reorganize changes into multiple commits
git reset HEAD~1
git add src/feature-a.js
git commit -m "Add feature A"
git add src/feature-b.js
git commit -m "Add feature B"Hard reset (discard everything):
# ❌ DANGER: Undo commit AND discard changes
git reset --hard HEAD~1
# Before:
# Commit: abc1234 "Add feature"
# After:
# Commit: def5678
# Status: All changes from abc1234 GONE!
# ⚠️ CANNOT UNDO! (unless using reflog)Reset to specific commit:
# Reset to specific commit hash
git reset --hard abc1234
# Reset to remote state
git reset --hard origin/main
# Reset to 5 commits ago
git reset --hard HEAD~5Impact: Undo commits with control over what's kept
When to use:
- Reorganize commits (soft/mixed)
- Undo commits on private branch
- Start over from specific point (hard)
- Never on public branches!
Pattern 5: Revert (Safe Public Undo)
Problem: Undo commit that's already pushed/shared
# ❌ BAD: Reset public branch
git reset --hard HEAD~1
git push --force origin main # Breaks others' work!
# ✅ GOOD: Revert (creates new commit)
git revert HEAD
# Creates new commit that undoes changes
# Commit history:
# abc1234 - Add feature
# def5678 - Revert "Add feature" ← New commitRevert specific commit:
# Revert by hash
git revert abc1234
# Revert with custom message
git revert abc1234 -m "Revert feature due to bug #123"
# Revert without auto-commit (review first)
git revert abc1234 --no-commit
git status # Review changes
git commit -m "Revert feature - found security issue"Revert multiple commits:
# Revert range (inclusive)
git revert abc1234..def5678
# Revert each commit individually
git revert HEAD~3..HEAD
# Revert last 3 commits
git revert HEAD~3 HEAD~2 HEAD~1Revert merge commit:
# Merge commits have two parents
# Must specify which parent to revert to
# -m 1: Keep first parent (usually main)
git revert -m 1 merge-commit-hash
# Example:
git revert -m 1 HEAD # Revert last mergeImpact: Safe undo for public history
When to use:
- Undo commit on main/shared branch
- Production hotfix (revert bad deploy)
- Preserve history (audit trail)
- Safe collaborative undo
Pattern 6: Recover Deleted Commits (Reflog)
Problem: Accidentally deleted commits, need recovery
# ❌ PANIC: "I lost my work!"
git reset --hard HEAD~5 # Deleted 5 commits!
git log # Commits are gone!
# ✅ SOLUTION: Reflog saves you!
git reflog
# abc1234 HEAD@{0}: reset: moving to HEAD~5
# def5678 HEAD@{1}: commit: Feature work ← Lost commit!
# ghi9012 HEAD@{2}: commit: More work ← Lost commit!
# Recover to specific state
git reset --hard HEAD@{1}
# or
git reset --hard def5678
# Commits recovered!View reflog:
# See all operations
git reflog
# See last 10
git reflog -10
# See specific branch reflog
git reflog show feature-branch
# See with dates
git reflog --date=relative
git reflog --date=isoRecover deleted branch:
# Deleted branch
git branch -D feature-branch
# Error: branch deleted!
# Find last commit
git reflog | grep feature-branch
# abc1234 HEAD@{5}: checkout: moving from feature-branch to main
# Recreate branch
git branch feature-branch abc1234
git checkout feature-branch
# Branch recovered!Reflog for specific operations:
# Find when file was deleted
git reflog -- path/to/file.js
# Find all commits
git reflog show --all
# Find specific commit message
git reflog | grep "important feature"Impact: Recover "lost" commits and branches
When to use:
- Accidentally reset
- Deleted branch
- Lost commits after rebase
- Any "oops" moment
- Within 90 days (default reflog expiry)
Pattern 7: Undo Pushed Commits
Problem: Pushed commits that need to be undone
# ❌ BAD: Reset and force push
git reset --hard HEAD~3
git push --force origin main # Dangerous for team!
# ✅ GOOD: Revert pushed commits
git revert HEAD~3..HEAD
git push origin main
# Or revert individually
git revert HEAD
git revert HEAD~1
git revert HEAD~2
git push origin mainFor your own branch:
# If it's your feature branch (not shared)
git reset --hard HEAD~2
git push --force-with-lease origin feature-branch
# Safe because:
# 1. Your branch only
# 2. Not sharing with others
# 3. Using --force-with-leaseFor shared branch (proper procedure):
# Step 1: Communicate with team
# "I'm reverting commits abc-def on main"
# Step 2: Revert commits
git revert abc1234..def5678
# Step 3: Push
git push origin main
# Step 4: Tell team to pull
# "Pull latest main, bad commits reverted"Emergency rollback:
# Production is broken, must rollback NOW
# Option 1: Revert merge
git revert -m 1 HEAD # Revert last merge
git push origin main
# Option 2: Revert to specific commit
git revert --no-commit HEAD~5..HEAD
git commit -m "Emergency rollback to stable version"
git push origin main
# Option 3: Create tag, then revert
git tag broken-version
git revert -m 1 HEAD
git push origin main
git push origin broken-version # For investigation laterImpact: Safe undo even after pushing
When to use:
- Bug found in production
- Reverting bad merge
- Undoing public commits
- Team collaboration
Pattern 8: Reset vs Revert Decision Guide
Problem: Which undo method to use?
Decision tree:
Is commit pushed/shared?
├─ No → Use RESET (clean history)
│ ├─ Want to keep changes? → git reset --soft HEAD~1
│ ├─ Want to unstage? → git reset HEAD~1
│ └─ Want to discard? → git reset --hard HEAD~1
│
└─ Yes → Use REVERT (safe public undo)
├─ Single commit → git revert abc1234
├─ Multiple commits → git revert abc1234..def5678
└─ Merge commit → git revert -m 1 merge-hashComparison table:
| Operation | Reset | Revert |
| Changes history | Yes | No |
| Creates new commit | No | Yes |
| Safe for public branches | ❌ No | ✅ Yes |
| Removes from history | ✅ Yes | ❌ No |
| Undoes specific commit | ❌ Harder | ✅ Easy |
| Can recover with reflog | ✅ Yes | N/A |
Examples:
# Local experiment failed
git reset --hard HEAD~5 # OK: Not pushed
# Production bug
git revert HEAD # CORRECT: Already pushed
# Reorganize commits before PR
git reset --soft HEAD~3 # OK: Your branch
git commit # Combine into one commit
# Undo commit on main
git revert abc1234 # CORRECT: Shared branchImpact: Choose correct undo method
When to use:
- Reset: Private branches, local work
- Revert: Public branches, shared work
Common Workflows
Fix Commit Message Typo
git commit -m "Add authentification" # Typo!
git commit --amend -m "Add authentication"
git push --force-with-lease origin feature-branchReorganize Last 3 Commits
git reset --soft HEAD~3
# All changes now staged
git add src/feature-a.js
git commit -m "Add feature A"
git add src/feature-b.js
git commit -m "Add feature B"
git push --force-with-lease origin feature-branchRecover Deleted Branch
git branch -D feature-branch # Oops!
git reflog | grep feature-branch
# Find commit: abc1234
git checkout -b feature-branch abc1234Revert Production Bug
git checkout main
git pull origin main
git revert abc1234 # Bad commit
git push origin mainUndo Local Uncommitted Changes
# Save first (optional)
git stash
# Discard all changes
git restore .
# Or specific file
git restore src/app.jsTroubleshooting
Amend after push
# Error: Updates were rejected
# If your branch only:
git push --force-with-lease origin feature-branch
# If shared:
# Don't amend! Create new commit insteadCan't find commit in reflog
# Reflog expires after 90 days
# Check if still exists
git fsck --lost-found
# Recover from lost+found
ls .git/lost-found/commit/
git show <hash>
git branch recovered-branch <hash>Reset wrong commit
# Used reset but meant different commit
git reflog
# Find pre-reset state
git reset --hard HEAD@{1}Revert created conflict
# Revert may conflict with newer changes
git revert abc1234
# CONFLICT!
# Resolve conflict
git add resolved-file.js
git revert --continueBest Practices
- Check status first - Always
git statusbefore major undo - Prefer revert for public - Use revert on shared branches
- Reset for private only - Only reset on your own branches
- Backup before hard reset - Create branch or stash
- Amend before push - OK to amend local commits
- Force-with-lease - Safer than --force
- Reflog expires - Recover within 90 days
- Communicate - Tell team about major undos
Related Sub-Skills
- Made changes after undo? →
/git/basics - Need to redo after reset? →
/git/history - Pushed after undo? →
/git/remote - Conflicts after revert? →
/git/conflicts
Quick Command Reference
# Unstage
git restore --staged file.js # Unstage file
git restore --staged . # Unstage all
# Discard changes
git restore file.js # Discard file changes
git restore . # Discard all changes
# Amend
git commit --amend # Change last commit
git commit --amend --no-edit # Add to last commit
# Reset
git reset --soft HEAD~1 # Undo commit, keep staged
git reset HEAD~1 # Undo commit, unstage
git reset --hard HEAD~1 # Undo commit, discard
# Revert
git revert HEAD # Revert last commit
git revert abc1234 # Revert specific commit
git revert -m 1 merge-hash # Revert merge
# Recover
git reflog # View reflog
git reset --hard HEAD@{1} # Recover from reflog
git branch recovered abc1234 # Recover deleted branchLast Updated: 2025-02-11 Version: 1.0.0
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

