Introduction
When you work in an interactive Copilot CLI session, Copilot can make changes to files, run shell commands, and modify your repository. If the result isn't what you expected, you can rewind to a previous point in the session to undo those changes.
You can trigger a rewind by pressing Esc twice when Copilot is idle, or by using the /undo slash command (or its alias /rewind).
When you select a point to rewind to, you can choose whether to Rewind the conversation only or Rewind the conversation and restore files.
Rewind works in any directory, including folders that aren't Git repositories. It restores only the files that Copilot changed.
This article explains how to roll back changes. For more conceptual information about rewinding to an earlier point in a session, see Canceling a GitHub Copilot CLI operation and rolling back changes.
Prerequisites
- A rewind point must exist. You can't roll back before your first prompt in a session.
- File restoration is only available for sessions that tracked file changes. If you resume a session that started before file-change tracking was enabled, only conversation rewind is offered. Start a new session to be able to restore file changes.
- File restoration skips files you changed yourself. Files whose current contents no longer match what Copilot last wrote (for example, because you edited them afterward), and files that were too large to back up, are left untouched rather than overwritten.
- Rewind isn't available for remote-backed sessions, or while the session still has work in progress.
Rolling back with a double Esc keypress
Warning
- Rewinding cannot be undone. Once you roll back, later session history is permanently removed.
- If you choose to restore files, Copilot restores only the files it changed, and skips any file whose current contents no longer match what it last wrote, so your own later edits aren't overwritten.
Pressing Esc twice only opens the rewind picker when Copilot is idle. For details of what a double Esc does when an operation is in progress, see Canceling a GitHub Copilot CLI operation and rolling back changes.
When Copilot has finished responding to a prompt you've entered:
-
Make sure the input area is empty and no work is in progress. If there's text in the input area, pressing Esc twice in quick succession clears the text instead of opening the picker.
-
Press Esc twice in quick succession to open the rewind picker.
The picker lists available rewind points for the current session, with the most recent first. The ten most recent points are displayed at once. If there are more than ten, use the ↑ and ↓ arrow keys to scroll through them. For each rewind point, the beginning of the prompt you entered is shown, along with how long ago you submitted it. For turns that changed files, the number of lines added and removed by that turn is also shown.
-
Choose a rewind point and press Enter.
Choosing a rewind point opens an action menu where you can select Conversation only or Conversation + files. The latter is unavailable for a rewind point when neither that turn nor any later turn changed any files that can be restored. Before restoring, Copilot shows a per-file preview of the changes so you can confirm.
Note
The rewind is applied relative to the state immediately before Copilot started working on the prompt, not immediately after it finished working on the prompt.
The prompt you selected is shown in the input area, so you can edit and resubmit it, if required.
Rolling back with the /undo slash command
The /undo slash command, and its alias /rewind, provide an alternative way of opening the rewind picker.
Both commands produce the same result that you get by pressing Esc twice when Copilot is idle and there is no text in the input area.
Verifying the rollback
After rolling back, you can use Git commands to verify the state of your repository and confirm that it matches your expectations.
Typing ! allows you to run shell commands directly from the Copilot CLI input prompt, so you don't need to exit the CLI to check the repository state.
| To do this | Enter this command |
|---|---|
| Check which files show as modified, staged, or untracked. | ! git status |
| Show the SHA and commit message of the current commit. | ! git log --oneline -1 |
| Review the unstaged changes. | ! git diff |