Prompt Details
Model
Chat - (gpt-5.6)
Token size
349
Example input
[GOAL]: undo my last commit but keep the changes
[SITUATION]: I committed too early, nothing pushed yet
[BRANCH_AND_REMOTE]: on a feature branch, origin remote, not pushed
[CAUTION_LEVEL]: cautious, do not lose work
[OUTPUT_PREFERENCE]: commands plus a short explanation
Example output
1. COMMANDS
Safe assumption: Your last commit is the current HEAD, it has not been pushed, and you want to keep both the changes and the staging state.
Bash
git status
Bash
git reset --soft HEAD~1
2. WHAT EACH DOES
git status — Confirms you're on the expected branch and shows your current working tree before making any changes.
git reset --soft HEAD~1 — Removes the last commit while keeping all its changes staged (ready to recommit). No file contents are lost.
3. WATCH OUT
git reset changes your local branch history. In this case, that's safe because you said the commit has not been pushed.
--soft does not discard any work. Your files stay exactly as they were in the last commit, and they remain staged.
Double-check git status first to make sure you don't have unrelated uncommitted changes that you might confuse with the restored commit.
If you had already pushed this commit, you should not use this approach without understanding the implications, since rewriting shared history can disrupt collaborators.
4. UNDO
If you decide you actually wanted the original commit back, you can restore it using the previous HEAD reference:
Bash
git reset --soft ORIG_HEAD
If ORIG_HEAD is unavailable, you can find the previous commit in the reflog:
Bash
git reflog
Then reset back to the commit you want (replace <commit> with the hash from the reflog):
Bash
git reset --soft <commit>
5. ALTERNATIVE
If your goal is to keep the changes but unstage them so you can review or selectively stage files before recommitting, use:
Bash
git reset HEAD~1
This removes the last commit and keeps all changes in your working directory, but they will no longer be staged. This is also a safe, non-destructive option when the commit has not been pushed.
By purchasing this prompt, you agree to our terms of service
GPT-5.6
Never google a git command again. Describe what you want to do in plain English (undo a commit, fix a branch, resolve a conflict, clean up history) and get the exact git commands in order, a plain-English explanation of each, what to watch out for, and how to undo it if it goes wrong. You give your goal, your current situation, and how cautious you want to be, so the steps fit your real repo. Great for developers, students, and anyone who freezes at the terminal. From stuck to fixed, safely.
...more
Added over 1 month ago
