Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/mubshrx/git-snapshot/llms.txt

Use this file to discover all available pages before exploring further.

The restore command applies a snapshot’s saved state back to your working directory, with options for selective restoration.

Syntax

git-snapshot restore <name> [options]

Parameters

  • name: The snapshot name, hash, or partial identifier to restore

Options

  • --staged-only: Restore only staged changes
  • --unstaged-only: Restore only unstaged changes
  • --untracked-only: Restore only untracked files
If no option is specified, all changes (staged, unstaged, and untracked) are restored.

Examples

Restore full snapshot

git-snapshot restore my-feature
Output:
Warning: You have uncommitted changes that will be overwritten!

Are you sure you want to continue? [y/N] y
Restoring snapshot: my-feature.a1b2c3d4.snapshot

Discarding current changes...
Restoring 2 staged file(s)...
Restoring 1 unstaged file(s)...
Restoring 3 untracked file(s)...

Snapshot restored successfully!

Restore by hash

git-snapshot restore a1b2c3d4

Restore only staged changes

git-snapshot restore my-feature --staged-only
Output:
Restoring snapshot: my-feature.a1b2c3d4.snapshot
(selective restore)

Restoring 2 staged file(s)...

Snapshot restored successfully!

Restore only unstaged changes

git-snapshot restore my-feature --unstaged-only
Output:
Warning: You have uncommitted changes that will be overwritten!

Are you sure you want to continue? [y/N] y
Restoring snapshot: my-feature.a1b2c3d4.snapshot
(selective restore)

Discarding current changes...
Restoring 1 unstaged file(s)...

Snapshot restored successfully!

Restore only untracked files

git-snapshot restore my-feature --untracked-only
Output:
Restoring snapshot: my-feature.a1b2c3d4.snapshot
(selective restore)

Restoring 3 untracked file(s)...

Snapshot restored successfully!

Behavior

Full restore

When restoring without selective options:
  1. Prompts for confirmation if there are uncommitted changes
  2. Discards current changes with git checkout -- . and git reset HEAD
  3. Restores staged files and stages them with git add
  4. Restores unstaged files to the working tree
  5. Restores untracked files

Selective restore

With --staged-only, --unstaged-only, or --untracked-only:
  • Only the specified category of changes is restored
  • When restoring staged or unstaged changes, current changes are discarded first
  • When restoring only untracked files, existing changes are preserved
  • The output indicates “(selective restore)”
Restoring staged or unstaged changes will overwrite your current working directory changes. Make sure to create a snapshot of your current state first if you want to preserve it.

Repository matching

The restore command only allows restoring snapshots from the current repository:
git-snapshot restore other-repo-snapshot
Output:
Error: Snapshot 'other-repo-snapshot' belongs to a different repository

Multiple matches

If multiple snapshots match the query, you’ll be prompted to choose:
git-snapshot restore feature
Output:
Multiple snapshots match 'feature':

  [1] a1b2c3d4  main  2026-03-03 14:23:45
  [2] b5c6d7e8  develop  2026-03-02 10:15:30

Enter number to restore (or 'q' to quit): 1
Restoring snapshot: feature.a1b2c3d4.snapshot
...

Error handling

Snapshot not found

git-snapshot restore nonexistent
Output:
Error: Snapshot 'nonexistent' not found

Missing parameter

git-snapshot restore
Output:
Error: Please provide a snapshot name or hash
Usage: git-snapshot restore <name> [--staged-only|--unstaged-only|--untracked-only]

Aborting confirmation

git-snapshot restore my-feature
Output:
Warning: You have uncommitted changes that will be overwritten!

Are you sure you want to continue? [y/N] n
Aborted.

Build docs developers (and LLMs) love