undo-mistake
/undo-mistake
Safely undo git mistakes - discard uncommitted edits, unstage files, fix the last commit, recover from committing on the default branch or a teammate's branch - without force-pushing. Use when someone says "undo", "I messed up", "wrong branch", or "committed something by accident".
- Author
- kmedi355 ↗
- Repository
- team-git-skills ↗
- Licence
- MIT
- Last repository change
- 11.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 11.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Safely undo git mistakes - discard uncommitted edits, unstage files, fix the last commit, recover from committing on the default branch or a teammate's branch - without force-pushing. Use when someone says "undo", "I messed up", "wrong branch", or "committed something by accident".
Triggers from the description
Original author description
Safely undo git mistakes - discard uncommitted edits, unstage files, fix the last commit, recover from committing on the default branch or a teammate's branch - without force-pushing. Use when someone says "undo", "I messed up", "wrong branch", or "committed something by accident".
How it works
- 0. Context
SKILL.md preview
---
name: undo-mistake
description: Safely undo git mistakes - discard uncommitted edits, unstage files, fix the last commit, recover from committing on the default branch or a teammate's branch - without force-pushing. Use when someone says "undo", "I messed up", "wrong branch", or "committed something by accident".
---
# I messed something up
Guide: if the repo has a CONTRIBUTING.md, the matching section is "I messed something up". The steps below work without it.
## 0. Context
- **Default branch** (`<default>`): `gh repo view --json defaultBranchRef -q .defaultBranchRef.name`, falling back to `git symbolic-ref --short refs/remotes/origin/HEAD` (drop the `origin/`). If both fail, ask.
- **What happened:** `git status` and `git log --oneline -5`, plus `git log @{u}..HEAD` to see what's not pushed yet. Explain it to the user before changing anything.
Prefer the least destructive fix. Ask before anything that throws away work.
| Situation | Fix |
|---|---|
| Throw away uncommitted edits to a file | `git restore <file>`. **Confirm first: this can't be undone.** |
| Staged a file by mistake | `git restore --staged <file>` (keeps the edits) |
| Typo in the last commit message, **not pushed yet** | `git commit --amend -m "<new message>"` |
| Forgot a file in the last commit, **not pushed yet** | `git add <file>` then `git commit --amend --no-edit` |
| Committed on `<default>` (or a teammate's branch) by accident, **not pushed yet** | `git branch <name>/<desc>` (saves the work), then `git reset --hard origin/<branch-you-were-on>`, then `git checkout <name>/<desc>`. Confirm with the user before the reset. |
| A bad commit **already pushed** to your own branch | `git revert <commit>` then push. This adds an undo commit; history stays intact. |
| Pushed to `<default>` or a teammate's branch by accident | Don't try to fix it with force-push. Tell the user to let the team know; usually `git revert <commit>` on that branch (with the owner's OK) is the fix. |
| A secret (API key, password) was committed | Not pushed: unstage it or amend it out. Pushed: tell the user to revoke the key at the provider **now** and tell the team. Removing it from git doesn't make it safe again. |
**Never** run `git push --force`, `git reset --hard` on a pushed branch, or rewrite shared history without the user explicitly asking after you've explained what it does. If it's not on this list, stop and suggest asking the team.
Versions
The database has no other skills named undo-mistake.
Database snapshot: 13.11.2026 · package version 0d781f1d24fc (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100undo
Safely undo the most recent git commit(s) on a feature branch. TRIGGER when the user says "undo my last commit", "undo last N commits", "oops revert that commit", "undo the commit but keep my changes", "uncommit", "revert my last change", "take back that commit", "/nyann:undo".… - 100git-undo
Recover safely from Git mistakes such as discard, unstage, amend, reset, revert, restore lost commits via reflog, recover deleted branches, and fix bad rebases. Chooses the least-destructive fix and protects against data loss. Use when something in Git went wrong and needs undoing. - 100git-undo-recovery
Recover from a git mistake - lost commits after `reset --hard`, a deleted branch, a commit made on the wrong branch, a bad merge or rebase, a dropped stash, a force-push that overwrote someone's work, files lost to `checkout .`, `restore` or `clean`. Use this whenever the user… - 98repo-kickoff
Use when starting a new code project or repository, when asked to write or check a repo's README, requirements, .gitignore, Python version or other setup files, or to audit whether a repo's docs match its code; also when asked to run a task through the git routine (start a task… - 100git-rescue
Recover from git accidents with git-rescue. Use when the user says they messed up git or lost work, for example after reset --hard, a deleted branch, a dropped stash, a rebase or merge stuck or gone wrong, commits on a detached HEAD, files they staged and then lost, or "how do I… - 100revert
Git-aware revert that understands Draft tracks, phases, and tasks. Safely undo work at task, phase, or track level. Use when the user asks to 'revert this track', 'undo a phase', 'revert task X', or says 'roll back the last task', 'undo this work'.