Manage sessions and history
Resume, browse, and rewind your conversations with Gemini CLI. In this guide, you’ll learn how to switch between tasks, manage your session history, and undo mistakes using the rewind feature.
Prerequisites
Section titled “Prerequisites”- Gemini CLI installed and authenticated.
- At least one active or past session.
How to resume where you left off
Section titled “How to resume where you left off”It’s common to switch context—maybe you’re waiting for a build and want to work on a different feature. Gemini makes it easy to jump back in.
Scenario: Resume the last session
Section titled “Scenario: Resume the last session”The fastest way to pick up your most recent work is with the --resume flag (or
-r).
gemini -rThis restores your chat history and memory, so you can say “Continue with the next step” immediately.
Scenario: Browse past sessions
Section titled “Scenario: Browse past sessions”If you want to find a specific conversation from yesterday, use the interactive browser.
Command: /resume
This opens a searchable list of all your past sessions. You’ll see:
- A timestamp (e.g., “2 hours ago”).
- The first user message (helping you identify the topic).
- The number of turns in the conversation.
Select a session and press Enter to load it.
How to manage your workspace
Section titled “How to manage your workspace”Over time, you’ll accumulate a lot of history. Keeping your session list clean helps you find what you need.
Scenario: Deleting sessions
Section titled “Scenario: Deleting sessions”In the /resume browser, navigate to a session you no longer need and press
x. This permanently deletes the history for that specific conversation.
You can also manage sessions from the command line:
# List all sessions with their IDsgemini --list-sessions
# Delete a specific session by ID or indexgemini --delete-session 1How to rewind time (Undo mistakes)
Section titled “How to rewind time (Undo mistakes)”Gemini CLI’s Rewind feature is like Ctrl+Z for your workflow.
Scenario: Triggering rewind
Section titled “Scenario: Triggering rewind”At any point in a chat, type /rewind or press Esc twice.
Scenario: Choosing a restore point
Section titled “Scenario: Choosing a restore point”You’ll see a list of your recent interactions. Select the point before the undesired changes occurred.
Scenario: Choosing what to revert
Section titled “Scenario: Choosing what to revert”Gemini gives you granular control over the undo process. You can choose to:
- Rewind conversation: Only remove the chat history. The files stay changed. (Useful if the code is good but the chat got off track).
- Revert code changes: Keep the chat history but undo the file edits. (Useful if you want to keep the context but retry the implementation).
- Rewind both: Restore everything to exactly how it was.
How to fork conversations
Section titled “How to fork conversations”Sometimes you want to try two different approaches to the same problem.
- Start a session and get to a decision point.
- Save the current state with
/chat save decision-point. - Try your first approach.
- Later, use
/chat resume decision-pointto fork the conversation back to that moment and try a different approach.
This creates a new branch of history without losing your original work.
Next steps
Section titled “Next steps”- Learn about Checkpointing to understand the underlying safety mechanism.
- Explore Task planning to keep complex sessions organized.
- See the Command reference for all
/chatand/resumeoptions.