Guide · Undo and Git · ★★☆☆☆
How to undo in Claude Code: rewind, checkpoints and Git
Claude broke something and you want the old version back. Rewind undoes Claude's edits in one session with two key presses. Git keeps every version of your project for good, whatever changed it. You need both.
By Arthur Hsiao · Last updated · 8 min read
Two safety nets. Before each prompt you send, Claude Code saves a checkpoint of the files Claude edits, and rewinding puts them back. It keeps the 100 most recent in a session, and they survive closing and resuming it. Git saves snapshots of your whole project folder, called commits, for as long as you keep the folder. Rewind is quick; Git is the backup. Checked against the checkpointing docs on 15 Nov 2026.
1Open the rewind menu
Either:
- press
Esctwice with an empty input box, or - type
/rewind(/undoand/checkpointdo the same).
If there is text in the input box, Esc Esc clears it instead. Press Up later to get the text back.
The menu lists the prompts you sent in this session. Pick the one to go back to: everything after it is what gets undone.
2Pick what to restore
| Choice | Files | Chat |
|---|---|---|
| Restore code and conversation | Back to that point | Back to that point |
| Restore conversation | Kept as they are now | Back to that point |
| Restore code | Back to that point | Kept |
| Summarize from here | Unchanged | Later messages squeezed into a summary |
| Never mind | Unchanged | Unchanged |
For a beginner, two of these cover most cases:
- Restore code and conversation: "that whole idea was wrong, start again from here". Your old prompt comes back in the input box, ready to edit and resend.
- Restore code: "keep talking, but put the files back". Useful when you want to tell Claude why the change was wrong.
The code choices only show if Claude edited files after that point. The summarize choices are for long sessions; see /clear vs /compact.
For a small mistake you can also just say it. In my sessions it's often two words, typed right after a change I didn't like: revert back. Claude edits the files back. That is a new edit, so it gets its own checkpoint, and you can still rewind past it.
3Know what rewind can't undo
This is the part that catches people:
- Shell commands. If Claude ran
rm,del,mvor a script that changed files, rewind won't bring those files back. The docs: "A file that only Bash commands changed isn't tracked and stays as it is." - Subagents. Edits made by a subagent (a helper Claude starts for a side job) usually aren't in your checkpoints. These very guides were written by a subagent, so a rewind in the main session wouldn't remove them. Git would.
- Your own edits outside Claude Code, and edits from another Claude session at the same time.
- Old sessions. Snapshots are deleted about 30 days after the session last saved one.
- Things outside your PC. A
git push, a deploy or a sent email is already out. Rewind only touches local files.
The docs call checkpoints "quick, session-level recovery" and say to keep using Git for real history. The rest of this guide is that Git part: five commands and a few prompts, not a Git course.
4Install Git and start a repo
On Windows, install Git for Windows. This PC runs git version 2.39.2.windows.1. Then, in your project folder:
git init
That makes the folder a repository (repo): Git now watches it. Nothing is saved until the first commit.
Before you commit, ask Claude to check that junk and secrets stay out. A .gitignore file is the list of files Git should never save (build output, node_modules, files with passwords). On this site I typed:
checking anything need to be gitignore
Claude listed what was already ignored (dist/, node_modules/, .angular/, my private ROADMAP.md), opened .vscode/mcp.json because "MCP configs sometimes hold API keys" (this one didn't), and said nothing needed adding. A check that finds nothing is still worth the ten seconds.
5Let Claude commit
In my sessions, Claude doesn't commit until I ask. Asking is short. My real prompts from this site:
Commit fix and carry on new tasks in roadmap
Bump up version and push it for me
Claude writes the commit message for you. One from this repo's log:
bf9c957 3.0.1 Fix distorted hero ASCII art, redraw hover canvas only on resize
Commit at the points you'd hate to lose: before a big task, and after something works. Then the worst case is one command, not a lost afternoon.
6Read the diff before you keep it
The diff is the change since your last commit. Three ways to read it:
git status git diff
git status lists the changed files. git diff shows the lines: - removed, + added. In Claude Code, /diff shows the same. In VS Code, the Source Control panel shows each changed file side by side.
You don't have to read code to use it. Ask Claude to explain the diff in plain words, file by file. If a file is in the list that you didn't expect Claude to touch, ask why before you commit.
7Go back when it breaks
Three cases, from small to big:
# Throw away the changes to one file since the last commit git restore index.html # See the commits, newest first git log --oneline # Make a new commit that undoes an old one git revert bf9c957
git restore is permanent for that file: changes you never committed are gone. git revert is the safe way to undo a commit, because it adds a new commit instead of deleting history.
You can also describe what broke and which commit was still good, and let Claude pick the command. Read the command at the permission prompt before you say yes.
Watch for history-rewriting commands. git reset --hard, git push --force and git clean delete work for good.
If Claude suggests one, say No at the permission prompt and ask for a safer way.
8Decide who pushes
A push sends your commits to GitHub (or another server), where other people and services see them. On this site a push to main deploys the live website, so I keep push as my own decision. Claude commits when I ask, and pushes only when I say "push".
It shows in how Claude reads a prompt. When I typed post first guide from roadmap and bumpup version to 3.5.0, Claude replied:
Nothing is committed or pushed, because I read "post" as "add the guide" and your notes say you push yourself.
That's the behaviour you want: when the wording is unclear, it doesn't push. More on deploying in deploy Angular to Cloudflare with Claude Code.
A Windows note: line endings
On Windows, Git converts line endings when it saves and checks out files (core.autocrlf is true on this PC). Git warns about it on commit, and the warning is harmless. It did break a script here once, which is told in which Claude Code model to use.
For a first repo to practise on, try a GitHub profile README with Claude Code.
Next: when a session gets long and Claude starts forgetting, see how to save tokens in Claude Code. To stop risky commands before they run, see Claude Code permissions. New here? Start with Claude Code for beginners.