nikivdev/code · error

failed to restore sync auto-stash automatically. Run `git st

Error message

failed to restore sync auto-stash automatically. Run `git stash list` and restore manually if needed.

What it means

Same auto-stash restore failure as the packet variant, but no repair packet path was available, so the message only suggests manual `git stash list` recovery. It signals that sync finished its transfer but your pre-sync local changes could not be reapplied.

Source

Thrown at src/sync.rs:5223

        write_sync_repair_packet(
            repo_root,
            SyncRepairKind::StashRestoreConflict,
            &conflicted_files,
            detail,
            None,
            Some(auto_stash_state),
            packet_dir_override,
        )
        .ok()
    };
    if detail.is_empty() {
        if let Some(packet_path) = repair_packet_path {
            bail!(
                "failed to restore sync auto-stash automatically. Run `:sync repair --packet {}` or `git stash list` and restore manually if needed.",
                packet_path.display()
            );
        }
        bail!(
            "failed to restore sync auto-stash automatically. Run `git stash list` and restore manually if needed."
        );
    }

    if let Some(packet_path) = repair_packet_path {
        if allow_autofix {
            match try_route_sync_conflicts_to_sync_agent(repo_root, &packet_path)? {
                SyncRepairRouteOutcome::Completed => {
                    restore_intent_to_add_paths(repo_root, &auto_stash_state.intent_to_add_paths)
                        .context("restored stash but could not restore intent-to-add markers")?;
                    if drop_latest_stash_if_present(repo_root)? {
                        sync_progressln!(
                            "  ✓ Sync agent resolved stash conflicts and dropped auto-stash"
                        );
                    } else {
                        sync_progressln!("  ✓ Sync agent resolved stash conflicts");
                    }
                    return Ok(());

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run `git stash list` to find the auto-stash entry
  2. `git stash apply stash@{0}`, resolve any conflicts, then `git stash drop`
  3. Check `git status` for mid-merge state and resolve before re-running sync

Example fix

git stash apply stash@{0}
# resolve conflicts
git add -A
git stash drop stash@{0}
Defensive patterns

Strategy: fallback

Validate before calling

git stash list && git status --porcelain  # clean tree, no pending auto-stash

Try / catch

match sync_result {
    Err(e) if e.to_string().contains("failed to restore sync auto-stash") => {
        let _ = run("git", &["stash", "apply", "stash@{0}"]);
        // resolve conflicts, then git stash drop
    }
    r => r?,
}

Prevention

When it happens

Trigger: Stash pop/apply failed during `restore_stash` and `repair_packet_path` was None (no repair packet was created or it failed to produce a path).

Common situations: Stash conflicts after a remote sync; local untracked files colliding with stashed ones; a previous aborted sync left the repo dirty.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/08c0ee6c4b1608cf. Report an issue: GitHub.