Undo Last Commit

VerifiedSafe

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

Sby Skills Guide Bot
DevelopmentBeginner
306/2/2026
Claude Code
#git#undo#commit#reset#staging

Recommended for

Our review

Undo the last commit while keeping changes staged.

Strengths

  • Quick and non-destructive operation
  • Preserves changes ready for a new commit
  • Allows fixing the commit message or adding missing files

Limitations

  • Only works for the most recent commit (HEAD~1)
  • Not suitable for undoing multiple commits at once
  • Requires basic Git knowledge
When to use it

Use this skill when you committed too early and need to adjust the message or add missing files.

When not to use it

Avoid using it if the commit has already been pushed to a shared remote repository.

Security analysis

Safe
Quality score85/100

The command `git reset --soft HEAD~1` is a standard, non-destructive git operation that only moves the HEAD pointer backward and keeps changes staged. It does not involve any exfiltration, file deletion, or network access, and is restricted to git-related Bash commands.

No concerns found

Examples

Undo last commit
Undo the last commit but 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