Skip to content

Commit 346f3a2

Browse files
hubwriterCopilot
andauthored
Copilot CLI: Update the rewind functionality in roll-back-changes.md (#61760)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6cea860 commit 346f3a2

1 file changed

Lines changed: 31 additions & 10 deletions

File tree

content/copilot/how-tos/copilot-cli/use-copilot-cli/roll-back-changes.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Rolling back changes made during a {% data variables.copilot.copilot_cli %} session
33
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.'
55
versions:
66
feature: copilot
77
contentType: how-tos
@@ -18,34 +18,55 @@ docsTeamMetrics:
1818

1919
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.
2020

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**.
2237

2338
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).
2439

2540
## Prerequisites
2641

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

3046
## Rolling back with a double Esc keypress
3147

3248
> [!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.
3552
3653
When {% data variables.product.prodname_copilot_short %} has finished responding to a prompt you've entered:
3754

3855
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.
3956
1. Press <kbd>Esc</kbd> twice in quick succession to open the rewind picker.
4057

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

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

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

4768
> [!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.
4970
5071
The prompt you selected is shown in the input area, so you can edit and resubmit it, if required.
5172

0 commit comments

Comments
 (0)