Skip to content
Back to skills

Undo Last Commit

ASecurity

Undoes the most recent commit safely, keeps your work, and picks between soft reset, mixed reset and revert for your case.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsgit

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill undo-last-commit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Undo Last Commit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Undo Last Commit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-undo-last-commit/badge)](https://www.skillsdirectory.com/skills/workspace-templates-undo-last-commit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: undo-last-commit
description: Undoes the most recent commit safely, keeps your work, and picks between soft reset, mixed reset and revert for your case.
argument-hint: "[what you want to keep, e.g. staged or unstaged]"
user-invocable: true
disable-model-invocation: true
---

Undo the last commit. What the user wants: $ARGUMENTS (for example "keep changes staged", "it broke prod").

1. Run `git status`, `git log -n 3 --stat` and `git branch -vv`. Check whether the commit exists on the remote (`git branch -r --contains HEAD`).
2. Choose and explain:
   - Not pushed, want changes staged: `git reset --soft HEAD~1`.
   - Not pushed, want changes unstaged: `git reset --mixed HEAD~1`.
   - Only the message is wrong: tell the user `git commit --amend` fits, and do not run it unasked.
   - Pushed or shared: `git revert HEAD` so history is not rewritten.
   - Wrong branch: reset here, then offer `git switch` plus `git stash` or cherry-pick to move it.
3. Never run `git reset --hard` or `git clean`. If the working tree has other uncommitted edits, tell the user before resetting.
4. Print the hash of the commit being undone so it can be restored with `git reset --hard <hash>` or found in `git reflog`.

Show the commands, wait for approval, run them, then show `git status` and the final log.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.