Undo Last Commit

VerifiedSafe

Undo the last commit while keeping changes staged. Useful for fixing commit messages or adding missing files before committing again.

Sby Skills Guide Bot
DevelopmentBeginner
406/2/2026
Claude CodeCursorWindsurfCopilotCodex
#git#undo#commit#staging

Recommended for

Our review

Undoes the last commit while keeping changes staged.

Strengths

  • Allows fixing commit messages or adding missing files.
  • Does not delete file changes.
  • Non-destructive and easily reversible.

Limitations

  • Only works for the most recent commit on the current branch.
  • Not suitable for undoing commits already pushed (use git revert instead).
  • Does not handle multiple commits or complex merges.
When to use it

When you've committed with a wrong message or forgot files, and haven't pushed yet.

When not to use it

If the commit has already been pushed to a shared branch, prefer git revert to avoid rewriting history.

Security analysis

Safe
Quality score85/100

The skill only runs a standard, non-destructive git command ('git reset --soft HEAD~1') that keeps changes staged. It does not exfiltrate data, write files outside the repo, or execute external payloads. The allowed-tools are restricted to git, posing no security risk.

No concerns found

Examples

Undo last commit with bad message
Undo the last commit but keep changes staged so I can fix the commit message.
Add forgotten files to last commit
I forgot to include some files in the last commit. Undo the commit, add the files, and recommit.
Fix commit message using undo
I made a typo in the last commit message. Help me undo it without losing changes and then recommit with the correct message.

name: git-undo description: Undo the last commit while keeping changes staged. Use when you need to fix a commit message or add missing files. disable-model-invocation: true allowed-tools: Bash(git:*)

Git Undo

Undo the last commit but keep changes staged.

  1. Undo the last commit but keep the file changes in the staging area.
    • Command: git reset --soft HEAD~1
    • This allows you to fix the commit message or add missing files before committing again.
Related skills