How It Works
When you approve a tool that modifies the file system (likewrite_file or replace), Gemini CLI automatically creates a checkpoint.
Automatic Checkpoint
Before execution, the CLI creates a checkpoint containing:
- Git snapshot: Complete project state in a shadow repository
- Conversation history: Full chat history up to this point
- Tool call: The specific tool about to be executed
What’s Saved in a Checkpoint
Git Snapshot
Complete state of project files captured in a shadow Git repository at
~/.gemini/history/<project_hash>.Does not interfere with your project’s Git repository.Conversation History
Entire conversation with the agent up to the checkpoint moment.
Tool Call
The specific tool call that was about to be executed, stored for re-proposal.
Enabling Checkpointing
Checkpointing is disabled by default and must be enabled in yoursettings.json file.
The
--checkpointing command-line flag was removed in version 0.11.0. Use settings.json configuration only.Configuration
Add to yoursettings.json:
- User-Level
- Project-Level
- Using /settings
Edit
~/.gemini/settings.json to enable for all projects:Using the /restore Command
Once enabled, checkpoints are created automatically. Manage them with /restore.
List Available Checkpoints
Run without arguments to see all checkpoints:- Timestamp: When the checkpoint was created
- File name: The file being modified
- Tool name: The tool that was about to run
Restore a Specific Checkpoint
Use the checkpoint filename from the list:Storage Locations
Checkpoint data is stored locally on your machine.Git Snapshots
Shadow repository (does not interfere with your project Git):Checkpoint Metadata
Conversation history and tool calls:- Linux/macOS
- Windows
Use Cases
Safe Experimentation
Try risky refactors or experimental changes knowing you can instantly revert.
Review Before Commit
Review AI-generated changes, restore if needed, then commit manually.
Compare Approaches
Restore to try alternative implementations of the same feature.
Undo Mistakes
Quickly recover from unwanted changes without manually reverting files.
Checkpointing vs. Session Management
Understand the difference between these two features:| Feature | Checkpointing | Session Management |
|---|---|---|
| Purpose | Snapshot before file modifications | Save conversation history |
| Trigger | Before tool execution (automatic) | Continuous (automatic) |
| What’s Saved | Files + conversation + tool call | Conversation only |
| Command | /restore [checkpoint] | /resume or gemini --resume |
| Storage | checkpoints/ + history/ | chats/ |
| Use Case | Undo file changes | Resume work later |
Checkpointing focuses on file safety while session management focuses on conversation continuity.
Manual Conversation Checkpoints
For manual conversation state saving (without file snapshots), use/chat commands:
Best Practices
Enable Per Project
Enable checkpointing in project-level
settings.json for critical codebases while keeping it off for experimental projects.Review Before Restore
List checkpoints with
/restore to review the timestamp and file before restoring.Clean Up Old Checkpoints
Periodically remove old checkpoints from
~/.gemini/tmp/<project_hash>/checkpoints/ to manage disk space.Combine with Git
Use checkpointing for immediate safety and Git for long-term version control. Checkpoints complement, not replace, Git.
Troubleshooting
/restore command not available
/restore command not available
Cause: Checkpointing is not enabled.Solution: Add
"general": { "checkpointing": { "enabled": true } } to your settings.json.No checkpoints listed
No checkpoints listed
Cause: No file-modifying tools have been executed yet, or checkpoints were manually deleted.Solution: Approve a tool that modifies files (e.g.,
write_file) to create a checkpoint.Restore didn't revert my files
Restore didn't revert my files
Cause: Incorrect checkpoint selected, or files modified outside Gemini CLI.Solution:
- Verify the checkpoint filename matches the change you want to undo
- Check if files were modified by other tools/editors after the checkpoint
- Use Git directly for changes made outside Gemini CLI
Shadow Git repository conflicts
Shadow Git repository conflicts
Cause: Manual modifications to
~/.gemini/history/<project_hash>/.Solution: Do not manually edit the shadow repository. If corrupted, delete it and checkpointing will recreate it.Disk space issues
Disk space issues
Cause: Checkpoints accumulate over time for large projects.Solution:
- Manually delete old checkpoints from
~/.gemini/tmp/<project_hash>/checkpoints/ - Delete the shadow repository at
~/.gemini/history/<project_hash>/if no longer needed - Consider enabling checkpointing only for specific projects
Advanced Usage
Checkpoint File Structure
Checkpoint files are JSON with the following structure:Shadow Repository
The shadow Git repository at~/.gemini/history/<project_hash>/ contains:
- Commits for each checkpoint
- Complete file state snapshots
- No branches (linear history)
- Isolated from your project’s
.git/
Related Features
Session Management
Resume conversations with automatic history saving
Rewind
Navigate backward through conversation and file changes
Sandboxing
Isolated execution for additional safety
Next Steps
Configuration
Enable checkpointing in settings.json
Commands Overview
Learn about /restore and /rewind commands