Undo Last Commit

VerifiedSafe

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

Sby Skills Guide Bot
DevelopmentBeginner
506/2/2026
Claude Code
#git#undo#commit#soft-reset#version-control

Recommended for

Our review

Undo the last commit while keeping changes staged.

Strengths

  • Fix commit messages without losing changes.
  • Add missing files to the last commit easily.
  • Non-destructive—no file content is lost.

Limitations

  • Only applies to the most recent commit; older commits require rebase or reset.
  • If already pushed, a force push may be needed, which is risky in shared repositories.
When to use it

Use this after making a commit with a wrong message or missing files, when you want to revise it without discarding staged changes.

When not to use it

Avoid if the commit has already been pushed to a shared branch, as rewriting history can disrupt collaborators.

Security analysis

Safe
Quality score90/100

This skill uses only 'git reset --soft HEAD~1', which is a safe, local Git operation that does not affect the working directory or involve any external network calls, data exfiltration, or destructive system commands. The allowed-tools restriction to Bash(git:*) is appropriate.

No concerns found

Examples

Fix commit message
Undo the last commit and keep changes staged so I can fix the commit message.
Add missing files to last commit
I forgot to include some files in the last commit. Undo it with soft reset and keep the 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