| title | Canceling a {% data variables.copilot.copilot_cli %} operation and rolling back changes | ||
|---|---|---|---|
| shortTitle | Cancel and roll back | ||
| intro | Find out about the different ways to cancel an active {% data variables.product.prodname_copilot_short %} operation, and how to roll back changes made during a session if the result isn't what you expected. | ||
| versions |
|
||
| contentType | concepts | ||
| docsTeamMetrics |
|
||
| category |
|
When you work in an interactive {% data variables.copilot.copilot_cli_short %} session, you can press Esc or Ctrl+C to control what {% data variables.product.prodname_copilot_short %} is doing. Both keypresses can cancel operations, but they work slightly differently:
- Ctrl+C acts immediately, without a confirming second press—removing any queued prompts first (one per press), then canceling the current operation.
- A single Esc keypress gives you more gradual, staged control. While {% data variables.product.prodname_copilot_short %} is actively working, a single Esc 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.
If {% data variables.product.prodname_copilot_short %} has already made changes and you want to undo them, you can roll back your workspace to a previous point in the session. {% data variables.copilot.copilot_cli_short %} takes a snapshot of your workspace state each time you enter a prompt, and this allows you to rewind to an earlier state by pressing Esc twice when {% data variables.product.prodname_copilot_short %} is idle and the input area is empty.
Pressing Esc once performs different actions depending on the current state of the session:
| Current state | What pressing Esc does |
|---|---|
| {% data variables.product.prodname_copilot_short %} is active with no queued prompts. | Shows an "Esc again to cancel" reminder. The running operation is canceled only if you press Esc again within half a second. |
| {% data variables.product.prodname_copilot_short %} is active and there are queued prompts. | Shows the "Esc again to cancel" reminder. Pressing Esc again removes the most recently queued prompt. |
| A permission dialog is open. | A single Esc denies the pending request (no second press needed). |
| A dialog, overlay, or picker is open. | Closes the dialog, overlay, or picker. |
| {% data variables.product.prodname_copilot_short %} is idle. | Shows a brief reminder that pressing Esc again quickly will open the rewind picker. See Rolling back changes. |
The main difference between these two ways of canceling an operation is that Esc is designed for gradual, targeted intervention, while Ctrl+C is a hard stop.
Use Esc when you want to interact with {% data variables.product.prodname_copilot_short %} without necessarily ending the current operation. For example, if a permission dialog appears and you want to deny that specific request, pressing Esc dismisses the dialog and {% data variables.product.prodname_copilot_short %} 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 Esc removes the most recently queued prompt (repeat to remove earlier ones), while the current operation keeps running.
Use Ctrl+C when you want to cancel without the confirming second press that Esc requires. If no prompts are queued, a single Ctrl+C immediately cancels the active operation. If you have queued prompts, each Ctrl+C 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 Ctrl+C a second time within two seconds, when the input area is empty, exits the session entirely.
As a rule of thumb, use Esc when you want to intervene selectively, and Ctrl+C when you want to stop and start over.
While {% data variables.product.prodname_copilot_short %} is inactive and there is no text in the input area, you can press Esc twice to display a list of points in your current session that you can roll back to. Each point corresponds to a snapshot of your workspace that was taken immediately before {% data variables.product.prodname_copilot_short %} started working on the prompt shown in the list.
For full details of how to use the double Esc keypress to roll back changes made during a session, see AUTOTITLE.
Warning
{% data reusables.copilot.copilot-cli.cli-rewind-warning %}
When you select a snapshot from the rewind picker, the following actions occur:
- Git state is restored. The repository is checked out to the Git commit and branch recorded in the snapshot.
- Untracked files are cleaned. Files that did not exist at the time of the snapshot are removed.
- Modified files are restored. Files that were changed after the snapshot are reverted to their backed-up state, including permissions and staging state.
- Session history is truncated. The conversation is rewound to the point where the selected snapshot was taken. All messages and tool calls that occurred after that point are removed from the session.
- Snapshots are removed. The selected snapshot and all snapshots after it are permanently deleted. Only snapshots from earlier conversation steps remain available for future rewinds.
- Rollback confirmed. After the rollback, {% data variables.product.prodname_copilot_short %} displays a message indicating how many files were restored.
- Your prompt is restored. The prompt associated with the selected snapshot is placed in the input area.
Rewind is unavailable in the following situations:
- Files over 10 MB. Individual files larger than 10 MB are skipped during snapshot creation. Changes to these files are not restored during a rollback.
- More than 500 changed files. If more than 500 files were changed during a single step of a CLI conversation, a snapshot is not created for that step. You will not be able to roll back changes made in that step. Earlier snapshots are unaffected.