You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/copilot/how-tos/copilot-cli/use-copilot-cli/roll-back-changes.md
+31-10Lines changed: 31 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Rolling back changes made during a {% data variables.copilot.copilot_cli %} session
3
3
shortTitle: Roll back changes
4
-
intro: 'Rewind your {% data variables.copilot.copilot_cli_short %} session to a previous prompt to undo changes and restore your repository to a previous state.'
4
+
intro: 'Rewind your {% data variables.copilot.copilot_cli_short %} session to a previous prompt to undo changes in conversation history, and optionally restore files.'
5
5
versions:
6
6
feature: copilot
7
7
contentType: how-tos
@@ -18,34 +18,55 @@ docsTeamMetrics:
18
18
19
19
When you work in an interactive {% data variables.copilot.copilot_cli_short %} session, {% data variables.product.prodname_copilot_short %} 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.
20
20
21
-
When you enter a prompt, the first thing {% data variables.copilot.copilot_cli_short %} does is take a snapshot of your workspace state. This snapshot allows you to roll back to that point in the session if you need to. You can trigger a rewind by pressing <kbd>Esc</kbd> twice, or by using the `/undo` slash command.
21
+
You can trigger a rewind by pressing <kbd>Esc</kbd> twice, or by using the `/undo` slash command (or its alias `/rewind`).
22
+
23
+
{% data variables.copilot.copilot_cli_short %} supports two rewind behaviors:
24
+
25
+
***Git-based rewind**: rolls back to a workspace snapshot taken at the start of a prompt.
26
+
***Tools-based rewind**: lets you rewind conversation history only, or rewind conversation history and restore files that {% data variables.product.prodname_copilot_short %} changed.
27
+
28
+
> [!NOTE]
29
+
> Tools-based rewind is currently an experimental feature and is only available if you have used the `/experimental on` slash command, or the `--experimental` command line option.
30
+
31
+
{% data variables.copilot.copilot_cli_short %} automatically chooses one of these rewind behaviors based on your environment to provide the best possible rewind experience.
32
+
33
+
To tell which of the rewind behaviors is active:
34
+
35
+
* If the picker immediately shows snapshots and selecting one performs the rollback, you're using **Git-based rewind**.
36
+
* If selecting a rewind point opens an action menu with **Conversation only** and **Conversation + files**, you're using **tools-based rewind**.
22
37
23
38
This article explains how to roll back changes. For more conceptual information about rewinding to an earlier point in a session, see [AUTOTITLE](/copilot/concepts/agents/copilot-cli/cancel-and-roll-back).
24
39
25
40
## Prerequisites
26
41
27
-
***You must be working in a Git repository with at least one commit.** {% data variables.copilot.copilot_cli_short %} uses Git operations to track and restore workspace state.
28
-
***A snapshot must exist.** Snapshots are created automatically at the start of each of your interactions with {% data variables.product.prodname_copilot_short %} in a CLI session. You can't roll back changes made before your first prompt in a session, or to the repository state for a step where snapshot creation was skipped, see [Changes that can't be rolled back](/copilot/concepts/agents/copilot-cli/cancel-and-roll-back#changes-that-cant-be-rolled-back).
42
+
***A rewind point must exist.** You can't roll back before your first prompt in a session.
43
+
***For Git-based rewind only:** you must be in a Git repository with at least one commit.
44
+
***For tools-based rewind:** file restoration can be skipped for files that were changed after {% data variables.product.prodname_copilot_short %} last touched them.
29
45
30
46
## Rolling back with a double Esc keypress
31
47
32
48
> [!WARNING]
33
-
> * {% data reusables.copilot.copilot-cli.cli-rewind-warning %}
34
-
> * Rewinding cannot be undone. Once you roll back to a snapshot, all snapshots and session history after that point are permanently removed.
49
+
> * Rewinding cannot be undone. Once you roll back, later session history is permanently removed.
50
+
> * In **Git-based rewind**, rolling back 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 {% data variables.product.prodname_copilot_short %}, but also any manual edits and changes from shell commands. Any new files created in the workspace after the snapshot was taken are deleted, regardless of their Git status.
51
+
> * In **tools-based rewind**, you can choose whether to restore files. If you choose file restoration, files changed after {% data variables.product.prodname_copilot_short %} may be left unchanged to avoid overwriting your newer edits.
35
52
36
53
When {% data variables.product.prodname_copilot_short %} has finished responding to a prompt you've entered:
37
54
38
55
1. Make sure the input area is empty. If there's text in the input area, pressing <kbd>Esc</kbd> twice in quick succession clears the text.
39
56
1. Press <kbd>Esc</kbd> twice in quick succession to open the rewind picker.
40
57
41
-
The rewind picker lists the available snapshots for the current session, with the most recent first. The ten most recent snapshots are displayed. If there are more than ten snapshots available you can use the <kbd>↓</kbd> arrow key to scroll down through earlier snapshots.
58
+
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 <kbd>↓</kbd> arrow key to scroll down through earlier points.
59
+
For each rewind point, the beginning of the prompt you entered is shown, with an indication of how long ago you submitted it.
42
60
43
-
For each snapshot, the beginning of the prompt you entered is shown, with an indication of how long ago you submitted it.
61
+
1. Choose a rewind point.
44
62
45
-
1. Choose a snapshot to roll back to. This will return you to the state of the repository when you entered the associated prompt.
63
+
* In Git-based rewind, selecting a snapshot restores the workspace to the state at the start of that prompt.
64
+
* In tools-based rewind, after choosing a rewind point you can select:
65
+
***Conversation only** (history rewound, files unchanged), or
66
+
***Conversation + files** (history rewound and restorable files changed by {% data variables.product.prodname_copilot_short %} are restored).
46
67
47
68
> [!NOTE]
48
-
> The repository is rolled back to its state immediately before {% data variables.product.prodname_copilot_short %} started working on the prompt, not immediately after it finished working on the prompt.
69
+
> In Git-based rewind, the repository is rolled back to its state immediately before {% data variables.product.prodname_copilot_short %} started working on the prompt, not immediately after it finished working on the prompt.
49
70
50
71
The prompt you selected is shown in the input area, so you can edit and resubmit it, if required.
0 commit comments