Skip to main content

Canceling a GitHub Copilot CLI operation and rolling back changes

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.

Introduction

When you work in an interactive Copilot CLI session, you can press Esc or Ctrl+C to control what Copilot 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 Copilot 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 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 Esc 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.

What pressing Esc does in different situations

Pressing Esc once performs different actions depending on the current state of the session:

Current stateWhat pressing Esc does
Copilot 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.
Copilot 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.
Copilot is idle.Shows a brief reminder that pressing Esc again quickly will open the rewind picker. See Rolling back changes.

Pressing Esc 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 Esc does one of the following, in this order of priority:

  • Cancels a running shell command.
  • Stops the current response.
  • Stops background agents.
  • Clears text in the input area.
  • Exits shell mode.

If none of these applies, the rewind picker is displayed.

When to use Esc instead of Ctrl+C

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 Copilot 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 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 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.

Rolling back changes

While Copilot 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 prompt you submitted, and rewinding takes the session back to the state it was in immediately before Copilot started working on that prompt.

After you choose a rewind point, you decide whether to:

  • Rewind the conversation only, leaving your files untouched.
  • Rewind the conversation and restore files, which reverts the files Copilot changed while leaving your own later edits in place.

Because it restores only the files Copilot changed rather than your whole workspace, rewind works in any directory, including folders that aren't Git repositories.

For full details of how to use the double Esc keypress to roll back changes made during a session, see Rolling back changes made during a GitHub Copilot CLI session.

Warning

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.

What happens when you roll back

The actions that occur when you roll back depend on the option you choose.

If you choose to rewind the conversation and restore files:

  1. 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.
  2. 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.
  3. Obsolete snapshots are removed. The captured file changes for the discarded turns are cleaned up. Earlier points remain available for future rewinds.
  4. Rollback confirmed. After the rollback, Copilot displays a message indicating how many files were restored, and notes any files that were skipped.
  5. Your prompt is restored. The prompt associated with the selected point is placed in the input area, so you can edit and resubmit it.

If 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).

Changes that can't be rolled back

File restoration is skipped, or unavailable, in the following situations:

  • 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.
  • 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.
  • Files you changed yourself. Files whose current contents no longer match what Copilot last wrote are left untouched rather than overwritten.
  • 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.
  • Remote-backed or busy sessions. Rewind isn't available for remote-backed sessions, or while the session still has work in progress.

Further reading