home / skills / toilahuongg / shopify-agents-kit / git-undo
This skill helps you undo the last commit while keeping changes staged, enabling quick fixes to messages or added files before recommitting.
npx playbooks add skill toilahuongg/shopify-agents-kit --skill git-undoReview the files below or copy the command above to add this skill to your agents.
---
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.
This skill provides a quick Git workflow to undo the most recent commit while preserving your file changes in the staging area. It’s designed for situations where the last commit needs a corrected message, missing files, or other small fixes before re-committing. The command is safe for local commits and keeps your working tree intact.
The skill runs a soft reset to move HEAD back one commit without touching the index or working directory. Specifically, it executes git reset --soft HEAD~1, which unstages the last commit but leaves its changes staged and ready to modify. After running it you can edit the commit message, add or remove files, and create a corrected commit.
Will this delete my file changes?
No. git reset --soft HEAD~1 keeps your working directory and the index intact; only the commit reference is moved back one step.
Is it safe if I already pushed the commit to remote?
Not recommended. Rewriting a commit that’s been pushed can cause problems for collaborators. Use git revert or coordinate a force-push with the team if necessary.