[{"data":1,"prerenderedAt":52},["ShallowReactive",2],{"blog-undo-claude-code-changes":3,"blog-related-undo-claude-code-changes":36},{"slug":4,"title":5,"description":6,"category":7,"categoryId":8,"keyword":9,"date":10,"minutes":11,"body":12,"html":13,"headings":14},"undo-claude-code-changes","How to undo what Claude Code changed: \u002Frewind and git","Undo Claude Code's edits with \u002Frewind, git restore and reflog. What checkpoints cover, what they miss (bash, subagents), and habits that make undo painless.","Workflows","workflows","undo claude code changes","2026-11-17",5,"To undo what Claude Code just did, run `\u002Frewind` (alias `\u002Fundo`), pick the message you want to go back to, and choose to restore the code, the conversation, or both. That covers edits made with Claude's own file tools. For anything else, such as files changed by shell commands, you need git. This page explains where each tool stops, so you know which to reach for.\n\n## What are the three layers of undo?\n\n| Layer | Undoes | Does not cover |\n| --- | --- | --- |\n| `\u002Frewind` (checkpoints) | Claude's file edits in this session, and the conversation | Files only a bash command touched, other sessions, your manual edits |\n| Git | Anything committed, stashed or tracked | Untracked files you never added (unless you stash them) |\n| Your tool's own undo | Depends on the tool | Depends on the tool |\n\nUse `\u002Frewind` for \"that last prompt went wrong\". Use git for \"the last hour went wrong\", and commit before anything big so git has something to go back to.\n\n## How do you rewind in Claude Code?\n\nTwo ways to open the menu: type `\u002Frewind` (aliases `\u002Fundo` and `\u002Fcheckpoint`), or press `Esc` twice with an empty prompt box. If the box has text, double `Esc` clears it instead, and the text goes to your history so `Up` brings it back.\n\nThe menu lists the prompts you sent. Select one, then choose:\n\n- **Restore code and conversation**: both go back to that point.\n- **Restore conversation**: the messages rewind, the files stay as they are.\n- **Restore code**: the files rewind, the conversation stays.\n- **Summarize from here** \u002F **Summarize up to here**: compress part of the conversation to free context. It changes no files.\n- **Never mind**: close the menu.\n\nAfter a restore, the original prompt comes back into the input field so you can edit and resend it. That is the real use of rewind: \"same request, better wording\" without the debris of the failed attempt in your context. Checkpoints are saved with the conversation, so `\u002Frewind` still works after you resume a session.\n\n## What does a checkpoint not cover?\n\nThe docs list the limits, and they matter:\n\n- **Bash command changes.** If Claude already edited a file with its edit tools, `\u002Frewind` also undoes later bash changes to that file. A file that only a bash command changed (`sed -i`, a formatter, `rm`, a generator) is not tracked and stays as it is.\n- **Subagents.** A subagent's edits usually are not captured in your session's checkpoints, with one exception: a foreground skill that runs as a fork. A background `\u002Fcode-review --fix` is in the same boat.\n- **External changes.** Edits you make yourself, or that another Claude session makes, are normally not captured.\n- **Symlinks and hard links.** Restore skips them and warns `Restored the code, but skipped N files`. This bites with dotfile managers and pnpm.\n- **Old checkpoints.** Claude keeps file snapshots for the 100 most recent checkpoints of a session, and deletes a session's snapshots after about 30 days by default (`cleanupPeriodDays` in settings changes that).\n- **Mid-turn messages.** A message you typed while Claude was working can be marked \"No code restore\". Select the prompt that started the turn instead.\n\nCheckpoints are session-level recovery, not version history. The docs say so in as many words.\n\n## How do you undo with git?\n\nWhen `\u002Frewind` does not reach it, git does. The commands worth memorizing:\n\n```sh\ngit status                      # what changed\ngit diff                        # how it changed\ngit restore path\u002Fto\u002Ffile        # discard unstaged changes to one file\ngit restore .                   # discard all unstaged changes (careful)\ngit stash -u                    # park everything, including untracked files\ngit clean -n                    # dry run: list untracked files that would go\ngit clean -fd                   # then actually delete them\n```\n\nIf Claude already committed and you want that commit gone but the changes kept:\n\n```sh\ngit reset --soft HEAD~1         # undo the commit, keep changes staged\n```\n\nAnd when something truly disappeared (a bad `reset --hard`, a deleted branch), `git reflog` lists where `HEAD` has been, and `git switch -c rescue \u003Chash>` brings a state back. Git keeps those entries for weeks by default, so you can almost always get back.\n\n`git restore .` and `git clean -fd` delete work without asking, and untracked files are not in git at all. Run the dry run first.\n\n## How do you try something risky and keep an exit?\n\nMake the exit before you need it:\n\n1. **Commit first.** A clean tree means `git restore .` is a full reset. \"Commit what we have\" is a prompt worth saying before a large refactor.\n2. **Use a branch or a worktree.** `git switch -c experiment` costs nothing. A [worktree](\u002Fblog\u002Fclaude-code-git-worktrees) isolates the experiment completely, and removing it removes the work.\n3. **Plan first.** In [plan mode](\u002Fblog\u002Fclaude-code-plan-mode) Claude proposes before it edits, so a bad idea costs a rejected plan instead of an undo.\n4. **Branch the conversation.** `\u002Fbranch` copies the conversation so far and switches you into the copy, leaving the original intact, so you can explore another direction without losing the first.\n5. **Keep permission prompts on for destructive commands.** See [permission modes](\u002Fblog\u002Fclaude-code-permission-modes).\n\nIf you want it automatic, a `PreToolUse` [hook](\u002Fblog\u002Fclaude-code-hooks) can run a script of yours (a `git stash create`, say) before shell commands.\n\n## What if the conversation is the problem, not the files?\n\nSometimes the code is fine and the session has gone sideways: it keeps repeating a wrong assumption, or its context is full of a dead end. Choose **Restore conversation** to rewind the messages and keep the code, or **Summarize from here** to compress the noisy part. `\u002Fclear` starts fresh and saves the old session for `\u002Fresume`. If the context is simply full, see [Claude Code's context window](\u002Fblog\u002Fclaude-code-context-window).\n\n## In Relais\n\nRelais puts a ↺ icon on each of your messages: \"Undo changes from here\". It shows a confirmation, runs a dry run first, then calls Claude Code's own file-checkpoint rewind, so it has the same limits: files changed by bash commands are not covered. Claude learns about the undo with your next message. Relais also snapshots each file before a session first edits it, which is how the Changes tab marks a session's files with a dot, including files outside git. Discard there sends every version it replaces to the Trash. See [features](\u002Ffeatures).","\u003Cp>To undo what Claude Code just did, run \u003Ccode>\u002Frewind\u003C\u002Fcode> (alias \u003Ccode>\u002Fundo\u003C\u002Fcode>), pick the message you want to go back to, and choose to restore the code, the conversation, or both. That covers edits made with Claude&#39;s own file tools. For anything else, such as files changed by shell commands, you need git. This page explains where each tool stops, so you know which to reach for.\u003C\u002Fp>\n\u003Ch2 id=\"what-are-the-three-layers-of-undo\">\u003Ca class=\"anchor\" href=\"#what-are-the-three-layers-of-undo\" aria-label=\"Link to this section\">#\u003C\u002Fa>What are the three layers of undo?\u003C\u002Fh2>\n\u003Cdiv class=\"table-wrap\">\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>Layer\u003C\u002Fth>\u003Cth>Undoes\u003C\u002Fth>\u003Cth>Does not cover\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>\u003Ccode>\u002Frewind\u003C\u002Fcode> (checkpoints)\u003C\u002Ftd>\u003Ctd>Claude&#39;s file edits in this session, and the conversation\u003C\u002Ftd>\u003Ctd>Files only a bash command touched, other sessions, your manual edits\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Git\u003C\u002Ftd>\u003Ctd>Anything committed, stashed or tracked\u003C\u002Ftd>\u003Ctd>Untracked files you never added (unless you stash them)\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Your tool&#39;s own undo\u003C\u002Ftd>\u003Ctd>Depends on the tool\u003C\u002Ftd>\u003Ctd>Depends on the tool\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003C\u002Fdiv>\n\u003Cp>Use \u003Ccode>\u002Frewind\u003C\u002Fcode> for &quot;that last prompt went wrong&quot;. Use git for &quot;the last hour went wrong&quot;, and commit before anything big so git has something to go back to.\u003C\u002Fp>\n\u003Ch2 id=\"how-do-you-rewind-in-claude-code\">\u003Ca class=\"anchor\" href=\"#how-do-you-rewind-in-claude-code\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you rewind in Claude Code?\u003C\u002Fh2>\n\u003Cp>Two ways to open the menu: type \u003Ccode>\u002Frewind\u003C\u002Fcode> (aliases \u003Ccode>\u002Fundo\u003C\u002Fcode> and \u003Ccode>\u002Fcheckpoint\u003C\u002Fcode>), or press \u003Ccode>Esc\u003C\u002Fcode> twice with an empty prompt box. If the box has text, double \u003Ccode>Esc\u003C\u002Fcode> clears it instead, and the text goes to your history so \u003Ccode>Up\u003C\u002Fcode> brings it back.\u003C\u002Fp>\n\u003Cp>The menu lists the prompts you sent. Select one, then choose:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Restore code and conversation\u003C\u002Fstrong>: both go back to that point.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Restore conversation\u003C\u002Fstrong>: the messages rewind, the files stay as they are.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Restore code\u003C\u002Fstrong>: the files rewind, the conversation stays.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Summarize from here\u003C\u002Fstrong> \u002F \u003Cstrong>Summarize up to here\u003C\u002Fstrong>: compress part of the conversation to free context. It changes no files.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Never mind\u003C\u002Fstrong>: close the menu.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>After a restore, the original prompt comes back into the input field so you can edit and resend it. That is the real use of rewind: &quot;same request, better wording&quot; without the debris of the failed attempt in your context. Checkpoints are saved with the conversation, so \u003Ccode>\u002Frewind\u003C\u002Fcode> still works after you resume a session.\u003C\u002Fp>\n\u003Ch2 id=\"what-does-a-checkpoint-not-cover\">\u003Ca class=\"anchor\" href=\"#what-does-a-checkpoint-not-cover\" aria-label=\"Link to this section\">#\u003C\u002Fa>What does a checkpoint not cover?\u003C\u002Fh2>\n\u003Cp>The docs list the limits, and they matter:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Bash command changes.\u003C\u002Fstrong> If Claude already edited a file with its edit tools, \u003Ccode>\u002Frewind\u003C\u002Fcode> also undoes later bash changes to that file. A file that only a bash command changed (\u003Ccode>sed -i\u003C\u002Fcode>, a formatter, \u003Ccode>rm\u003C\u002Fcode>, a generator) is not tracked and stays as it is.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Subagents.\u003C\u002Fstrong> A subagent&#39;s edits usually are not captured in your session&#39;s checkpoints, with one exception: a foreground skill that runs as a fork. A background \u003Ccode>\u002Fcode-review --fix\u003C\u002Fcode> is in the same boat.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>External changes.\u003C\u002Fstrong> Edits you make yourself, or that another Claude session makes, are normally not captured.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Symlinks and hard links.\u003C\u002Fstrong> Restore skips them and warns \u003Ccode>Restored the code, but skipped N files\u003C\u002Fcode>. This bites with dotfile managers and pnpm.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Old checkpoints.\u003C\u002Fstrong> Claude keeps file snapshots for the 100 most recent checkpoints of a session, and deletes a session&#39;s snapshots after about 30 days by default (\u003Ccode>cleanupPeriodDays\u003C\u002Fcode> in settings changes that).\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Mid-turn messages.\u003C\u002Fstrong> A message you typed while Claude was working can be marked &quot;No code restore&quot;. Select the prompt that started the turn instead.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>Checkpoints are session-level recovery, not version history. The docs say so in as many words.\u003C\u002Fp>\n\u003Ch2 id=\"how-do-you-undo-with-git\">\u003Ca class=\"anchor\" href=\"#how-do-you-undo-with-git\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you undo with git?\u003C\u002Fh2>\n\u003Cp>When \u003Ccode>\u002Frewind\u003C\u002Fcode> does not reach it, git does. The commands worth memorizing:\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"sh\">\u003Ccode>git status                      # what changed\ngit diff                        # how it changed\ngit restore path\u002Fto\u002Ffile        # discard unstaged changes to one file\ngit restore .                   # discard all unstaged changes (careful)\ngit stash -u                    # park everything, including untracked files\ngit clean -n                    # dry run: list untracked files that would go\ngit clean -fd                   # then actually delete them\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>If Claude already committed and you want that commit gone but the changes kept:\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"sh\">\u003Ccode>git reset --soft HEAD~1         # undo the commit, keep changes staged\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>And when something truly disappeared (a bad \u003Ccode>reset --hard\u003C\u002Fcode>, a deleted branch), \u003Ccode>git reflog\u003C\u002Fcode> lists where \u003Ccode>HEAD\u003C\u002Fcode> has been, and \u003Ccode>git switch -c rescue &lt;hash&gt;\u003C\u002Fcode> brings a state back. Git keeps those entries for weeks by default, so you can almost always get back.\u003C\u002Fp>\n\u003Cp>\u003Ccode>git restore .\u003C\u002Fcode> and \u003Ccode>git clean -fd\u003C\u002Fcode> delete work without asking, and untracked files are not in git at all. Run the dry run first.\u003C\u002Fp>\n\u003Ch2 id=\"how-do-you-try-something-risky-and-keep-an-exit\">\u003Ca class=\"anchor\" href=\"#how-do-you-try-something-risky-and-keep-an-exit\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you try something risky and keep an exit?\u003C\u002Fh2>\n\u003Cp>Make the exit before you need it:\u003C\u002Fp>\n\u003Col>\n\u003Cli>\u003Cstrong>Commit first.\u003C\u002Fstrong> A clean tree means \u003Ccode>git restore .\u003C\u002Fcode> is a full reset. &quot;Commit what we have&quot; is a prompt worth saying before a large refactor.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Use a branch or a worktree.\u003C\u002Fstrong> \u003Ccode>git switch -c experiment\u003C\u002Fcode> costs nothing. A \u003Ca href=\"\u002Fblog\u002Fclaude-code-git-worktrees\">worktree\u003C\u002Fa> isolates the experiment completely, and removing it removes the work.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Plan first.\u003C\u002Fstrong> In \u003Ca href=\"\u002Fblog\u002Fclaude-code-plan-mode\">plan mode\u003C\u002Fa> Claude proposes before it edits, so a bad idea costs a rejected plan instead of an undo.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Branch the conversation.\u003C\u002Fstrong> \u003Ccode>\u002Fbranch\u003C\u002Fcode> copies the conversation so far and switches you into the copy, leaving the original intact, so you can explore another direction without losing the first.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Keep permission prompts on for destructive commands.\u003C\u002Fstrong> See \u003Ca href=\"\u002Fblog\u002Fclaude-code-permission-modes\">permission modes\u003C\u002Fa>.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>If you want it automatic, a \u003Ccode>PreToolUse\u003C\u002Fcode> \u003Ca href=\"\u002Fblog\u002Fclaude-code-hooks\">hook\u003C\u002Fa> can run a script of yours (a \u003Ccode>git stash create\u003C\u002Fcode>, say) before shell commands.\u003C\u002Fp>\n\u003Ch2 id=\"what-if-the-conversation-is-the-problem-not-the-files\">\u003Ca class=\"anchor\" href=\"#what-if-the-conversation-is-the-problem-not-the-files\" aria-label=\"Link to this section\">#\u003C\u002Fa>What if the conversation is the problem, not the files?\u003C\u002Fh2>\n\u003Cp>Sometimes the code is fine and the session has gone sideways: it keeps repeating a wrong assumption, or its context is full of a dead end. Choose \u003Cstrong>Restore conversation\u003C\u002Fstrong> to rewind the messages and keep the code, or \u003Cstrong>Summarize from here\u003C\u002Fstrong> to compress the noisy part. \u003Ccode>\u002Fclear\u003C\u002Fcode> starts fresh and saves the old session for \u003Ccode>\u002Fresume\u003C\u002Fcode>. If the context is simply full, see \u003Ca href=\"\u002Fblog\u002Fclaude-code-context-window\">Claude Code&#39;s context window\u003C\u002Fa>.\u003C\u002Fp>\n\u003Ch2 id=\"in-relais\">\u003Ca class=\"anchor\" href=\"#in-relais\" aria-label=\"Link to this section\">#\u003C\u002Fa>In Relais\u003C\u002Fh2>\n\u003Cp>Relais puts a ↺ icon on each of your messages: &quot;Undo changes from here&quot;. It shows a confirmation, runs a dry run first, then calls Claude Code&#39;s own file-checkpoint rewind, so it has the same limits: files changed by bash commands are not covered. Claude learns about the undo with your next message. Relais also snapshots each file before a session first edits it, which is how the Changes tab marks a session&#39;s files with a dot, including files outside git. Discard there sends every version it replaces to the Trash. See \u003Ca href=\"\u002Ffeatures\">features\u003C\u002Fa>.\u003C\u002Fp>\n",[15,18,21,24,27,30,33],{"id":16,"text":17},"what-are-the-three-layers-of-undo","What are the three layers of undo?",{"id":19,"text":20},"how-do-you-rewind-in-claude-code","How do you rewind in Claude Code?",{"id":22,"text":23},"what-does-a-checkpoint-not-cover","What does a checkpoint not cover?",{"id":25,"text":26},"how-do-you-undo-with-git","How do you undo with git?",{"id":28,"text":29},"how-do-you-try-something-risky-and-keep-an-exit","How do you try something risky and keep an exit?",{"id":31,"text":32},"what-if-the-conversation-is-the-problem-not-the-files","What if the conversation is the problem, not the files?",{"id":34,"text":35},"in-relais","In Relais",[37,42,47],{"slug":38,"title":39,"description":40,"category":7,"categoryId":8,"keyword":41,"date":10,"minutes":11},"claude-code-multi-repo-projects","Claude Code across several repositories: --add-dir and layouts","How to work with Claude Code on a project split across repos: launch from a parent folder, --add-dir, what config loads from extra folders, and commits.","claude code multiple repositories",{"slug":43,"title":44,"description":45,"category":7,"categoryId":8,"keyword":46,"date":10,"minutes":11},"claude-code-commit-and-pull-requests","Commit, push and open a pull request with Claude Code","How to have Claude Code write commit messages, push a branch and open a PR with gh: prompts that work, permission rules, attribution settings and checks.","claude code commit and pull request",{"slug":48,"title":49,"description":50,"category":7,"categoryId":8,"keyword":51,"date":10,"minutes":11},"claude-code-git-worktrees","Git worktrees with Claude Code: parallel features, no conflicts","Run Claude Code in a git worktree with one flag: separate branches, no stepping on each other's files. Setup, cleanup, base branches and the gotchas.","claude code git worktrees",1794931098788]