{"meta":{"title":"Canceling a GitHub Copilot CLI operation and rolling back changes","intro":"Find out about the different ways to cancel an active Copilot operation, and how to roll back changes made during a session if the result isn't what you expected.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/en/enterprise-cloud@latest/copilot/concepts","title":"Concepts"},{"href":"/en/enterprise-cloud@latest/copilot/concepts/agents","title":"Agents"},{"href":"/en/enterprise-cloud@latest/copilot/concepts/agents/copilot-cli","title":"Copilot CLI"},{"href":"/en/enterprise-cloud@latest/copilot/concepts/agents/copilot-cli/cancel-and-roll-back","title":"Cancel and roll back"}],"documentType":"article"},"body":"# Canceling a GitHub Copilot CLI operation and rolling back changes\n\nFind out about the different ways to cancel an active Copilot operation, and how to roll back changes made during a session if the result isn't what you expected.\n\n## Introduction\n\nWhen you work in an interactive Copilot CLI session, you can press <kbd>Esc</kbd> or <kbd>Ctrl</kbd>+<kbd>C</kbd> to control what Copilot is doing. Both keypresses can cancel operations, but they work slightly differently:\n\n* <kbd>Ctrl</kbd>+<kbd>C</kbd> acts immediately, without a confirming second press—removing any queued prompts first (one per press), then canceling the current operation.\n* A single <kbd>Esc</kbd> keypress gives you more gradual, staged control. While Copilot is actively working, a single <kbd>Esc</kbd> doesn't cancel right away—it shows a reminder, and a second press carries out the next step: removing the most recently queued prompt, or canceling the operation once nothing is queued.\n\nIf Copilot has already made changes and you want to undo them, you can roll back to a previous point in the session. As Copilot works, Copilot CLI tracks the file changes it makes as it responds to each prompt. This lets you rewind to an earlier point by pressing <kbd>Esc</kbd> twice when Copilot is idle and the input area is empty. When you rewind, you choose whether to rewind the conversation only, or to also restore the files that Copilot changed.\n\n## What pressing Esc does in different situations\n\nPressing <kbd>Esc</kbd> once performs different actions depending on the current state of the session:\n\n| Current state                                   | What pressing <kbd>Esc</kbd> does                                                                                                                 |\n| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Copilot is active with no queued prompts.       | Shows an \"Esc again to cancel\" reminder. The running operation is canceled only if you press <kbd>Esc</kbd> again within half a second.           |\n| Copilot is active and there are queued prompts. | Shows the \"Esc again to cancel\" reminder. Pressing <kbd>Esc</kbd> again removes the most recently queued prompt.                                  |\n| A permission dialog is open.                    | A single <kbd>Esc</kbd> denies the pending request (no second press needed).                                                                      |\n| A dialog, overlay, or picker is open.           | Closes the dialog, overlay, or picker.                                                                                                            |\n| Copilot is idle.                                | Shows a brief reminder that pressing <kbd>Esc</kbd> again quickly will open the rewind picker. See [Rolling back changes](#rolling-back-changes). |\n\nPressing <kbd>Esc</kbd> twice quickly, when Copilot is idle, allows you to roll back to an earlier point in the session. If an operation is in progress, a double <kbd>Esc</kbd> does one of the following, in this order of priority:\n\n* Cancels a running shell command.\n* Stops the current response.\n* Stops background agents.\n* Clears text in the input area.\n* Exits shell mode.\n\nIf none of these applies, the rewind picker is displayed.\n\n## When to use Esc instead of Ctrl+C\n\nThe main difference between these two ways of canceling an operation is that <kbd>Esc</kbd> is designed for gradual, targeted intervention, while <kbd>Ctrl</kbd>+<kbd>C</kbd> is a hard stop.\n\nUse <kbd>Esc</kbd> when you want to interact with Copilot without necessarily ending the current operation. For example, if a permission dialog appears and you want to deny that specific request, pressing <kbd>Esc</kbd> dismisses the dialog and Copilot continues working—it just won't use the tool you denied. Similarly, if you've queued follow-up prompts and want to cancel them without interrupting the work already in progress, pressing <kbd>Esc</kbd> removes the most recently queued prompt (repeat to remove earlier ones), while the current operation keeps running.\n\nUse <kbd>Ctrl</kbd>+<kbd>C</kbd> when you want to cancel without the confirming second press that <kbd>Esc</kbd> requires. If no prompts are queued, a single <kbd>Ctrl</kbd>+<kbd>C</kbd> immediately cancels the active operation. If you have queued prompts, each <kbd>Ctrl</kbd>+<kbd>C</kbd> removes the most recently queued prompt—one per press—and cancels the active operation only once the queue is empty. Any file write that is already in progress will complete—files are not left corrupted mid-write—but any remaining planned changes are abandoned. Pressing <kbd>Ctrl</kbd>+<kbd>C</kbd> a second time within two seconds, when the input area is empty, exits the session entirely.\n\nAs a rule of thumb, use <kbd>Esc</kbd> when you want to intervene selectively, and <kbd>Ctrl</kbd>+<kbd>C</kbd> when you want to stop and start over.\n\n## Rolling back changes\n\nWhile Copilot is inactive and there is no text in the input area, you can press <kbd>Esc</kbd> twice to display a list of points in your current session that you can roll back to. Each point corresponds to a prompt you submitted, and rewinding takes the session back to the state it was in immediately before Copilot started working on that prompt.\n\nAfter you choose a rewind point, you decide whether to:\n\n* **Rewind the conversation only**, leaving your files untouched.\n* **Rewind the conversation and restore files**, which reverts the files Copilot changed while leaving your own later edits in place.\n\nBecause it restores only the files Copilot changed rather than your whole workspace, rewind works in any directory, including folders that aren't Git repositories.\n\nFor full details of how to use the double <kbd>Esc</kbd> keypress to roll back changes made during a session, see [Rolling back changes made during a GitHub Copilot CLI session](/en/enterprise-cloud@latest/copilot/how-tos/copilot-cli/use-copilot-cli/roll-back-changes).\n\n> \\[!WARNING]\n> Rewinding restores your entire workspace to the state it was in at the selected snapshot. This reverts all changes made after that point—not only changes made by Copilot, but also any manual edits, and changes resulting from shell commands. Any new files created in the workspace after the snapshot was taken are deleted, irrespective of their Git status.\n\n### What happens when you roll back\n\nThe actions that occur when you roll back depend on the option you choose.\n\nIf you choose to rewind the conversation **and** restore files:\n\n1. **Files are restored.** The files Copilot changed are reverted to the state they were in before the selected prompt. Files whose current contents no longer match what Copilot last wrote—for example, because you edited them yourself—are skipped so your later edits aren't overwritten.\n2. **Session history is truncated.** The conversation is rewound to the selected point. All messages and tool calls that occurred after that point are removed from the session.\n3. **Obsolete snapshots are removed.** The captured file changes for the discarded turns are cleaned up. Earlier points remain available for future rewinds.\n4. **Rollback confirmed.** After the rollback, Copilot displays a message indicating how many files were restored, and notes any files that were skipped.\n5. **Your prompt is restored.** The prompt associated with the selected point is placed in the input area, so you can edit and resubmit it.\n\nIf you choose to rewind the conversation only, your files are left untouched: the session history is truncated (step 2) and your prompt is restored to the input area (step 5).\n\n### Changes that can't be rolled back\n\nFile restoration is skipped, or unavailable, in the following situations:\n\n* **Files over 10 MB.** Individual files larger than 10 MB are skipped during capture, so changes to those files are not restored during a rollback.\n* **More than 500 changed files.** If more than 500 files were changed during a single turn, file changes for that turn are not captured, so you won't be able to restore files for it. Other turns are unaffected.\n* **Files you changed yourself.** Files whose current contents no longer match what Copilot last wrote are left untouched rather than overwritten.\n* **Sessions without file tracking.** If you resume a session that started before file-change tracking was enabled, only conversation rewind is available. Start a new session to be able to restore file changes.\n* **Remote-backed or busy sessions.** Rewind isn't available for remote-backed sessions, or while the session still has work in progress.\n\n## Further reading\n\n* [GitHub Copilot CLI command reference](/en/enterprise-cloud@latest/copilot/reference/copilot-cli-reference/cli-command-reference)"}