Undo Last Commit

VerifiedSafe

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

Sby Skills Guide Bot
DevelopmentBeginner
206/2/2026
Claude CodeCursorWindsurf
#git#undo#version-control

Recommended for

Our review

Undoes the last commit while keeping changes staged for re-committing.

Strengths

  • Allows fixing the commit message or adding missed files easily.
  • Does not delete any changes, unlike a hard reset.
  • Quick and straightforward one-command operation.

Limitations

  • Only works for the most recent commit (HEAD~1).
  • Does not affect untracked or unstaged changes.
  • Can be problematic if the commit has already been pushed to a shared branch.
When to use it

When you committed too early and need to adjust the commit message or include additional files.

When not to use it

If the commit has already been pushed to a shared remote, use `git commit --amend` or a revert instead.

Security analysis

Safe
Quality score85/100

The skill only uses 'git reset --soft HEAD~1', a standard git command that modifies local repository state. It does not execute arbitrary code, access sensitive files, or exfiltrate data. No destructive or obfuscated actions are present.

No concerns found

Examples

Undo last commit with message fix
Undo my last commit but keep the changes staged so I can fix the commit message.
Add forgotten file to previous commit
I forgot to include a file in the last commit. Undo the commit and keep the changes staged so I can add the missing file.
Reset soft after accidental commit
I accidentally committed too early. Use git reset --soft to undo the last commit and keep my changes staged.

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