Undo AI Changes With Git: A Rescue Guide
To undo AI changes, first protect what you have, then pick the smallest undo that solves the problem: your tool's rewind for today's edits, or Git for anything older. Git can only bring back what was saved, so work that was never saved may be gone for good.
Git is a tool that keeps every version you save, each with a short note. Your AI can run it for you, and you only need to know what to ask.
What should you do first?
Say you are making Marble Monastery, an invented puzzle game. At 23:40 you ask your AI to "improve the levels". At 23:55 you notice that it has rewritten all twelve, and the secret door in level 4 is gone.
Do not ask for one more fix. Stop, and make a copy of the whole project folder somewhere else. It takes ten seconds, and a mistake during the undo then costs you nothing.
Which undo fits?
| What happened | What to use |
|---|---|
| The last few requests went wrong, in this same session | Your tool's rewind |
| The AI ran commands, or a helper changed files | Git. Rewind may miss these changes |
| It broke days ago | Git: go back to the last good version |
| You want to try the older version but keep today's | Git: a side copy, called a branch |
| There is no Git yet and no saved version | Rewind if you can. Then set up Git today |
The rewind tools, as of 2 November 2026:
- Claude Code. Type
/rewind, or press Esc twice on an empty prompt. It keeps the last 100 checkpoints of a session. It can miss files changed only by commands and most edits made by helpers, and its docs say it does not replace Git. - Cursor. Use Restore Checkpoint on an earlier request. That reverts your files but not the conversation. Its docs say to use Git for permanent version control.
What can go wrong with the undo itself?
The Git book warns that this is "one of the few areas in Git where you may lose some work if you do it wrong". It adds that anything saved can almost always be recovered, while anything never saved "is likely never to be seen again".
So the danger is not the old versions. It is the unsaved work you have right now. That is why the prompt below saves it first and then waits for your yes.
If you would rather look at your history than ask about it, GitHub Desktop is a free app for Windows and Mac that shows your saved versions and what changed.
Once you are safe, stop this from happening again with a fence around what works.
Paste this to your AI
Something went wrong and I want to go back. Do not change or discard anything yet.
1. Tell me if there is unsaved work right now. List the files, taken from Git itself and not from memory.
2. Save that unsaved work as its own version on a side branch, so nothing is lost. Show me that it exists.
3. Show me the last ten saved versions with date and note, exactly as Git lists them. Draw them as a Mermaid diagram in order, and say in plain words what each one changed.
4. From the versions and their changes, show me where the game stopped doing what it is supposed to do. Tell me which version you would go back to and what makes you think it worked. If nothing shows that it worked, say "I do not know if this one worked".
5. Wait for my yes. Then go back, and show me Git's own output that we are on that version.
Never run a command that throws work away without asking me first. If this project has no Git yet, tell me, and set it up only after I have copied the folder.
Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
How to check it worked
- Open the game and try what you lost. In the example, walk to the secret door in level 4.
- Look for the side copy. Ask your AI to show you today's work on its side branch. It should still be there.
- Switch there and back once. Go to today's version and return. Now you know the way works.
- Open your folder copy. Check that it opens before you delete it, and keep it for a few days.
- Compare with the drawing. The version you are on should be the one you chose.