Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(remove): back up uncommitted changes before `--force` discards them (#4545)

Worktrunk Bot78e1357583f1
diff --git a/docs/src/content/docs/faq.md b/docs/src/content/docs/faq.md
index fb5d9769e..12adba5d2 100644
--- a/docs/src/content/docs/faq.md
+++ b/docs/src/content/docs/faq.md
@@ -137,7 +137,7 @@ Worktrunk stores repository state, caches, and logs under `.git/`:
| Location | Purpose | Created by |
|----------|---------|------------|
| `git config worktrunk.*` | Cached default branch, switch history, branch markers, custom variables | Various commands |
-| `refs/wt-backup/<branch>` | [Squash backups](/step/#wt-step-squash--recovering-staged-changes); preserved by state clearing | `wt step squash`, `wt merge` |
+| `refs/wt-backup/<branch>` | [Squash backups](/step/#wt-step-squash--recovering-staged-changes) and backups of changes discarded by `wt remove --force`; preserved by state clearing | `wt step squash`, `wt merge`, `wt remove --force` |
| `.git/wt/cache/{kind}/*.json` | Cached CI status, the largest PR/MR number seen (sizes the `wt list` CI column), and git command results (merge-tree, integration probes, diff stats, ancestry checks, ahead/behind counts, merge bases) | `wt list`, `wt merge`, `wt remove` |
| `.git/wt/cache/summary/{branch}/{hash}.json` | Cached LLM branch summaries, content-addressed by diff hash | `wt list --full`, `wt switch` (when `[list] summary = true`) |
| `.git/wt/cache/picker-preview/*.json` | Rendered preview panes for the interactive picker | `wt switch` |
@@ -188,7 +188,7 @@ Worktrunk can delete **worktrees** and **branches**. Both have safeguards.
### Worktree removal
-`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag removes the worktree anyway, discarding all of those changes.
+`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag removes the worktree anyway, after saving those changes (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and printing a command to recover them.
Removal also refuses, `--force` included, when the directory at a registered path no longer holds the worktree registered there — a clone made there after the worktree was deleted, say, or another worktree of the same repository moved onto the path. `--force` waives uncommitted changes, not the check for what the directory holds, and `git worktree remove` refuses the same cases.
diff --git a/docs/src/content/docs/remove.md b/docs/src/content/docs/remove.md
index 7b93b852a..83a7f48ae 100644
--- a/docs/src/content/docs/remove.md
+++ b/docs/src/content/docs/remove.md
@@ -82,6 +82,8 @@ $ wt remove feature -D # Delete unmerged branch
$ wt remove feature --force -D # Both
```
+Before `--force` discards uncommitted changes, Worktrunk saves them (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and prints a command to recover them in a new worktree.
+
Use `--no-delete-branch` to keep the branch regardless of merge status.
## Background removal
diff --git a/plugins/worktrunk/skills/worktrunk/reference/faq.md b/plugins/worktrunk/skills/worktrunk/reference/faq.md
index 898c49150..a7f9fea37 100644
--- a/plugins/worktrunk/skills/worktrunk/reference/faq.md
+++ b/plugins/worktrunk/skills/worktrunk/reference/faq.md
@@ -133,7 +133,7 @@ Worktrunk stores repository state, caches, and logs under `.git/`:
| Location | Purpose | Created by |
|----------|---------|------------|
| `git config worktrunk.*` | Cached default branch, switch history, branch markers, custom variables | Various commands |
-| `refs/wt-backup/<branch>` | [Squash backups](https://worktrunk.dev/step/#wt-step-squash--recovering-staged-changes); preserved by state clearing | `wt step squash`, `wt merge` |
+| `refs/wt-backup/<branch>` | [Squash backups](https://worktrunk.dev/step/#wt-step-squash--recovering-staged-changes) and backups of changes discarded by `wt remove --force`; preserved by state clearing | `wt step squash`, `wt merge`, `wt remove --force` |
| `.git/wt/cache/{kind}/*.json` | Cached CI status, the largest PR/MR number seen (sizes the `wt list` CI column), and git command results (merge-tree, integration probes, diff stats, ancestry checks, ahead/behind counts, merge bases) | `wt list`, `wt merge`, `wt remove` |
| `.git/wt/cache/summary/{branch}/{hash}.json` | Cached LLM branch summaries, content-addressed by diff hash | `wt list --full`, `wt switch` (when `[list] summary = true`) |
| `.git/wt/cache/picker-preview/*.json` | Rendered preview panes for the interactive picker | `wt switch` |
@@ -184,7 +184,7 @@ Worktrunk can delete **worktrees** and **branches**. Both have safeguards.
### Worktree removal
-`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag removes the worktree anyway, discarding all of those changes.
+`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag removes the worktree anyway, after saving those changes (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and printing a command to recover them.
Removal also refuses, `--force` included, when the directory at a registered path no longer holds the worktree registered there — a clone made there after the worktree was deleted, say, or another worktree of the same repository moved onto the path. `--force` waives uncommitted changes, not the check for what the directory holds, and `git worktree remove` refuses the same cases.
diff --git a/plugins/worktrunk/skills/worktrunk/reference/remove.md b/plugins/worktrunk/skills/worktrunk/reference/remove.md
index 5a1b33a3f..8b0d7129f 100644
--- a/plugins/worktrunk/skills/worktrunk/reference/remove.md
+++ b/plugins/worktrunk/skills/worktrunk/reference/remove.md
@@ -76,6 +76,8 @@ $ wt remove feature -D # Delete unmerged branch
$ wt remove feature --force -D # Both
```
+Before `--force` discards uncommitted changes, Worktrunk saves them (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and prints a command to recover them in a new worktree.
+
Use `--no-delete-branch` to keep the branch regardless of merge status.
## Background removal
diff --git a/skills/worktrunk/reference/faq.md b/skills/worktrunk/reference/faq.md
index 898c49150..a7f9fea37 100644
--- a/skills/worktrunk/reference/faq.md
+++ b/skills/worktrunk/reference/faq.md
@@ -133,7 +133,7 @@ Worktrunk stores repository state, caches, and logs under `.git/`:
| Location | Purpose | Created by |
|----------|---------|------------|
| `git config worktrunk.*` | Cached default branch, switch history, branch markers, custom variables | Various commands |
-| `refs/wt-backup/<branch>` | [Squash backups](https://worktrunk.dev/step/#wt-step-squash--recovering-staged-changes); preserved by state clearing | `wt step squash`, `wt merge` |
+| `refs/wt-backup/<branch>` | [Squash backups](https://worktrunk.dev/step/#wt-step-squash--recovering-staged-changes) and backups of changes discarded by `wt remove --force`; preserved by state clearing | `wt step squash`, `wt merge`, `wt remove --force` |
| `.git/wt/cache/{kind}/*.json` | Cached CI status, the largest PR/MR number seen (sizes the `wt list` CI column), and git command results (merge-tree, integration probes, diff stats, ancestry checks, ahead/behind counts, merge bases) | `wt list`, `wt merge`, `wt remove` |
| `.git/wt/cache/summary/{branch}/{hash}.json` | Cached LLM branch summaries, content-addressed by diff hash | `wt list --full`, `wt switch` (when `[list] summary = true`) |
| `.git/wt/cache/picker-preview/*.json` | Rendered preview panes for the interactive picker | `wt switch` |
@@ -184,7 +184,7 @@ Worktrunk can delete **worktrees** and **branches**. Both have safeguards.
### Worktree removal
-`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag removes the worktree anyway, discarding all of those changes.
+`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag removes the worktree anyway, after saving those changes (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and printing a command to recover them.
Removal also refuses, `--force` included, when the directory at a registered path no longer holds the worktree registered there — a clone made there after the worktree was deleted, say, or another worktree of the same repository moved onto the path. `--force` waives uncommitted changes, not the check for what the directory holds, and `git worktree remove` refuses the same cases.
diff --git a/skills/worktrunk/reference/remove.md b/skills/worktrunk/reference/remove.md
index 5a1b33a3f..8b0d7129f 100644
--- a/skills/worktrunk/reference/remove.md
+++ b/skills/worktrunk/reference/remove.md
@@ -76,6 +76,8 @@ $ wt remove feature -D # Delete unmerged branch
$ wt remove feature --force -D # Both
```
+Before `--force` discards uncommitted changes, Worktrunk saves them (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and prints a command to recover them in a new worktree.
+
Use `--no-delete-branch` to keep the branch regardless of merge status.
## Background removal
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index f8bf71303..e033e2bb7 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1375,6 +1375,8 @@ $ wt remove feature -D # Delete unmerged branch
$ wt remove feature --force -D # Both
```
+Before `--force` discards uncommitted changes, Worktrunk saves them (except ignored files and changes inside submodules) to `refs/wt-backup/<branch>` and prints a command to recover them in a new worktree.
+
Use `--no-delete-branch` to keep the branch regardless of merge status.
## Background removal
diff --git a/src/commands/step/squash.rs b/src/commands/step/squash.rs
index 921c73430..4720897e9 100644
--- a/src/commands/step/squash.rs
+++ b/src/commands/step/squash.rs
@@ -6,8 +6,7 @@ use worktrunk::HookType;
use worktrunk::config::UserConfig;
use worktrunk::git::WorkingTree;
use worktrunk::styling::{
- eprintln, format_with_gutter, hint_message, info_message, println, progress_message,
- success_message, suggest_command,
+ eprintln, format_with_gutter, info_message, println, progress_message, success_message,
};
use super::super::command_approval::{
@@ -296,26 +295,7 @@ pub fn handle_squash_in(
if has_staged {
let backup_message = format!("{} → {} (squash)", current_branch, span_target);
let backup = wt.create_safety_backup(&backup_message)?;
- let short_sha = repo.short_sha(&backup.sha)?;
- eprintln!(
- "{}",
- hint_message(cformat!(
- "Backup created @ <underline>{}</> ({short_sha})",
- backup.ref_name
- ))
- );
- let recovery_branch = format!("recovery/{short_sha}");
- let command = suggest_command(
- "switch",
- &[&recovery_branch],
- &["--create", "--base", &backup.sha, "--no-hooks"],
- );
- eprintln!(
- "{}",
- hint_message(cformat!(
- "To recover in a new worktree, run <underline>{command}</>"
- ))
- );
+ backup.print_recovery_hints(repo)?;
}
// Get commit subjects and bodies for the squash message
diff --git a/src/git/remove.rs b/src/git/remove.rs
index bd5786895..a76fb8caa 100644
--- a/src/git/remove.rs
+++ b/src/git/remove.rs
@@ -28,7 +28,9 @@
//! unconditionally (matching `git worktree remove`; `--force` does not
//! override it). The dirty-worktree gate is skipped with
//! [`RemoveOptions::force_worktree`], which reports the current uncommitted
-//! paths, or why they could not be read, before deletion instead. Why the
+//! paths, or why they could not be read, before deletion instead, and
+//! backs those changes up to `refs/wt-backup/<branch>` (ignored files
+//! excepted); a failed backup refuses the removal. Why the
//! dirty gate precedes the stop below: [`stage_worktree_removal`], "Why this order".
//! 2. **fsmonitor daemon stopped** (best effort). [`stop_fsmonitor_daemon`]
//! runs against the target worktree before its path disappears: it sends
@@ -471,7 +473,8 @@ pub fn remove_worktree_with_cleanup(
///
/// # Errors
///
-/// The ownership, lock, and dirty-worktree gates error. A
+/// The ownership, lock, and dirty-worktree gates error, as does a failed
+/// `--force` backup of uncommitted changes. A
/// failed rename is reported as `None`, not an error, and the daemon stop is
/// best-effort throughout.
pub fn stage_worktree_removal(
@@ -505,11 +508,20 @@ pub fn stage_worktree_removal(
// status command still cancels before any directory is removed.
match worktree.dirty_files() {
Ok(dirty_files) if !dirty_files.is_empty() => {
+ // `--force` waives the dirty gate, not recoverability. A
+ // failed backup refuses the removal rather than lose the
+ // changes it was meant to keep, so the discard is announced
+ // only once the backup exists.
+ let name = branch.unwrap_or_else(|| path_dir_name(worktree_path));
+ let backup = worktree
+ .create_removal_backup(&format!("{name} (remove --force)"))
+ .context("Failed to back up uncommitted changes; worktree not removed")?;
eprintln!(
"{}",
warning_message("Discarding uncommitted changes (--force):")
);
eprintln!("{}", format_with_gutter(&dirty_files.join("\n"), None));
+ backup.print_recovery_hints(repo)?;
}
Ok(_) => {}
Err(error) => {
diff --git a/src/git/repository/working_tree.rs b/src/git/repository/working_tree.rs
index 868f5c16d..12a3c1ab5 100644
--- a/src/git/repository/working_tree.rs
+++ b/src/git/repository/working_tree.rs
@@ -12,6 +12,8 @@ use path_slash::PathExt;
use crate::path::canonicalize_with_parents;
use crate::shell_exec::Cmd;
+use crate::styling::{eprintln, hint_message, suggest_command};
+use color_print::cformat;
use dunce::canonicalize;
use super::{GitError, LineDiff, Repository};
@@ -53,14 +55,41 @@ fn sweep_stale_temp_indexes(dir: &Path) {
}
}
-/// A squash safety backup: an immutable snapshot of the index and the ref
-/// whose reflog retains it. The backup commit's parent is the pre-squash HEAD.
+/// A safety backup: an immutable snapshot of uncommitted changes and the ref
+/// whose reflog retains it. The backup commit's parent is the HEAD the changes
+/// sat on — the pre-squash tip for a squash, the removed tip for a removal.
#[derive(Debug)]
pub struct SafetyBackup {
pub sha: String,
pub ref_name: String,
}
+impl SafetyBackup {
+ /// Print where the backup went and the command that recovers it.
+ pub fn print_recovery_hints(&self, repo: &Repository) -> anyhow::Result<()> {
+ let short_sha = repo.short_sha(&self.sha)?;
+ eprintln!(
+ "{}",
+ hint_message(cformat!(
+ "Backup created @ <underline>{}</> ({short_sha})",
+ self.ref_name
+ ))
+ );
+ let command = suggest_command(
+ "switch",
+ &[&format!("recovery/{short_sha}")],
+ &["--create", "--base", &self.sha, "--no-hooks"],
+ );
+ eprintln!(
+ "{}",
+ hint_message(cformat!(
+ "To recover in a new worktree, run <underline>{command}</>"
+ ))
+ );
+ Ok(())
+ }
+}
+
#[derive(Debug)]
struct NumstatEntry {
diff: LineDiff,
@@ -1279,27 +1308,56 @@ impl<'a> WorkingTree<'a> {
/// ```
pub fn create_safety_backup(&self, message: &str) -> anyhow::Result<SafetyBackup> {
let tree = self.run_command(&["write-tree"])?;
+ self.record_backup(tree.trim(), Some("HEAD"), message)
+ }
+
+ /// Back up every uncommitted change, as `wt remove --force` is about to
+ /// discard the worktree, to `refs/wt-backup/<branch>`.
+ ///
+ /// Like [`Self::create_safety_backup`], but the snapshot is what `git add
+ /// -A` would stage — staged, unstaged and untracked files — written through
+ /// a [`TempIndex`] so the real index is untouched. Ignored files are not
+ /// captured. The parent is `HEAD`, or none on an unborn branch, so the
+ /// backup also retains the branch tip after the branch is deleted.
+ pub fn create_removal_backup(&self, message: &str) -> anyhow::Result<SafetyBackup> {
+ let index = self.temp_index()?;
+ index.stage(crate::config::StageMode::All)?;
+ let tree = index.write_tree()?;
+ let parent = self.head_sha()?;
+ self.record_backup(&tree, parent.as_deref(), message)
+ }
+
+ /// Commit `tree` with `parent` and record it in the reflog of
+ /// `refs/wt-backup/<branch>`.
+ fn record_backup(
+ &self,
+ tree: &str,
+ parent: Option<&str>,
+ message: &str,
+ ) -> anyhow::Result<SafetyBackup> {
+ let mut args = vec!["commit-tree", "--no-gpg-sign", tree];
+ if let Some(parent) = parent {
+ args.extend(["-p", parent]);
+ }
+ args.extend(["-m", message]);
let backup_sha = self
- .run_command(&[
- "commit-tree",
- "--no-gpg-sign",
- tree.trim(),
- "-p",
- "HEAD",
- "-m",
- message,
- ])
+ .run_command(&args)
.context("Failed to create backup commit")?
.trim()
.to_string();
- // Get current branch name to use in the ref name
- let stdout = self.run_command(&["rev-parse", "--symbolic-full-name", "HEAD"])?;
- let branch = stdout
- .trim()
- .strip_prefix("refs/heads/")
- .unwrap_or("HEAD")
- .to_string();
+ // Read fresh rather than through the cached `branch()`: HEAD can have
+ // moved since it was cached. `rev-parse` fails on an unborn branch,
+ // which `symbolic-ref` still names. Detached HEAD backs up to
+ // `refs/wt-backup/HEAD`.
+ let branch = match self.run_command(&["rev-parse", "--symbolic-full-name", "HEAD"]) {
+ Ok(stdout) => stdout.trim().strip_prefix("refs/heads/").map(str::to_owned),
+ Err(_) => self
+ .run_command(&["symbolic-ref", "--short", "HEAD"])
+ .ok()
+ .map(|s| s.trim().to_owned()),
+ }
+ .unwrap_or_else(|| "HEAD".to_string());
// Slashes are valid in ref names, so use the branch as-is —
// flattening `/` to `-` would collide e.g. `a/b` with `a-b`.
@@ -1903,6 +1961,26 @@ mod tests {
);
}
+ #[test]
+ fn create_removal_backup_on_unborn_branch_has_no_parent() {
+ // An unborn branch has no HEAD commit to parent the backup, but still
+ // names the ref the backup goes to.
+ let test = TestRepo::with_initial_commit();
+ test.run_git(&["switch", "--orphan", "fresh"]);
+ std::fs::write(test.root_path().join("new.txt"), "unborn work").unwrap();
+ let repo = Repository::at(test.root_path()).unwrap();
+ let wt = repo.worktree_at(test.root_path());
+
+ let backup = wt.create_removal_backup("fresh (remove --force)").unwrap();
+
+ assert_eq!(backup.ref_name, "refs/wt-backup/fresh");
+ assert_eq!(
+ test.git_output(&["show", "refs/wt-backup/fresh:new.txt"]),
+ "unborn work"
+ );
+ assert_eq!(test.git_output(&["rev-list", "--count", &backup.sha]), "1");
+ }
+
#[test]
fn prewarm_at_populates_global_caches_for_a_fresh_repository() {
// `Repository::prewarm_at` is the eager merge: one rev-parse fills
diff --git a/tests/integration_tests/remove.rs b/tests/integration_tests/remove.rs
index 002218a5f..aab4133fa 100644
--- a/tests/integration_tests/remove.rs
+++ b/tests/integration_tests/remove.rs
@@ -1744,6 +1744,11 @@ fn test_remove_force_with_untracked_files(mut repo: TestRepo) {
"File should be untracked"
);
+ // Ignored files are not part of the backup
+ std::fs::write(worktree_path.join(".gitignore"), "build.out\n").unwrap();
+ std::fs::write(worktree_path.join("build.out"), "ignored content").unwrap();
+ let head = repo.git_output(&["-C", worktree_path.to_str().unwrap(), "rev-parse", "HEAD"]);
+
// Remove with --force should succeed
assert_cmd_snapshot!(make_snapshot_cmd(
&repo,
@@ -1751,6 +1756,57 @@ fn test_remove_force_with_untracked_files(mut repo: TestRepo) {
&["--force", "feature-untracked"],
None
));
+
+ // The discarded changes survive the worktree and branch in the backup ref,
+ // whose parent is the removed branch tip
+ let backup = "refs/wt-backup/feature-untracked";
+ assert_eq!(
+ repo.git_output(&["show", &format!("{backup}:devbox.lock")]),
+ "untracked content"
+ );
+ assert_eq!(repo.git_output(&["rev-parse", &format!("{backup}^")]), head);
+ let tree = repo.git_output(&["ls-tree", "--name-only", backup]);
+ assert!(
+ !tree.contains("build.out"),
+ "ignored file backed up: {tree}"
+ );
+}
+
+/// A `--force` backup that git can't take refuses the removal, before the
+/// discard is announced. An untracked nested repo with no commits can't be
+/// added to the snapshot.
+#[rstest]
+fn test_remove_force_refuses_when_backup_fails(mut repo: TestRepo) {
+ let worktree_path = repo.add_worktree("feature-unbackable");
+ let nested = worktree_path.join("nested");
+ std::fs::create_dir_all(&nested).unwrap();
+ repo.git_command()
+ .args(["init", "--quiet"])
+ .current_dir(&nested)
+ .run()
+ .unwrap();
+
+ let output = repo
+ .wt_command()
+ .args(["remove", "--force", "--foreground", "feature-unbackable"])
+ .current_dir(repo.root_path())
+ .output()
+ .unwrap();
+
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ assert_eq!(output.status.code(), Some(1), "{stderr}");
+ assert!(
+ stderr.contains("Failed to back up uncommitted changes; worktree not removed"),
+ "{stderr}"
+ );
+ assert!(
+ !stderr.contains("Discarding uncommitted changes"),
+ "{stderr}"
+ );
+ assert!(
+ worktree_path.exists(),
+ "worktree removed despite failed backup"
+ );
}
/// --force allows removal of dirty worktrees (issue #658)
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
index 799030aab..254fb24ab 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
@@ -168,6 +168,8 @@ Worktrunk has two force flags for different situations:
  wt remove feature -D # Delete unmerged branch
  wt remove feature --force -D # Both
+Before --force discards uncommitted changes, Worktrunk saves them (except ignored files and changes inside submodules) to refs/wt-backup/<branch> and prints a command to recover them in a new worktree.
+
Use --no-delete-branch to keep the branch regardless of merge status.
Background removal
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_force_with_force_delete.snap b/tests/snapshots/integration__integration_tests__remove__remove_force_with_force_delete.snap
index c01d03827..b6b09ff75 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_force_with_force_delete.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_force_with_force_delete.snap
@@ -64,3 +64,5 @@ exit_code: 0
◎ Removing feature-dirty-unmerged worktree (--force) & branch in background (--force-delete)
▲ Discarding uncommitted changes (--force):
  ?? untracked.txt
+↳ Backup created @ refs/wt-backup/feature-dirty-unmerged (e0aa6d9)
+↳ To recover in a new worktree, run wt switch --create --base e0aa6d9bf54c44e9ae1ca39a70ce921d69df30b0 --no-hooks recovery/e0aa6d9
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_force_with_modified_files.snap b/tests/snapshots/integration__integration_tests__remove__remove_force_with_modified_files.snap
index c0f03e16c..3bef9affd 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_force_with_modified_files.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_force_with_modified_files.snap
@@ -64,3 +64,5 @@ exit_code: 0
↳ Branch unmerged; to delete, run wt remove -D feature-modified
▲ Discarding uncommitted changes (--force):
  M tracked.txt
+↳ Backup created @ refs/wt-backup/feature-modified (985509f)
+↳ To recover in a new worktree, run wt switch --create --base 985509fc372ed70ebf9fa129f6baccda6bb3db6e --no-hooks recovery/985509f
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_force_with_staged_files.snap b/tests/snapshots/integration__integration_tests__remove__remove_force_with_staged_files.snap
index eda9f4ef1..ab86b609b 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_force_with_staged_files.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_force_with_staged_files.snap
@@ -63,3 +63,5 @@ exit_code: 0
◎ Removing feature-staged worktree (--force) & branch in background (same commit as main, _)
▲ Discarding uncommitted changes (--force):
  A staged.txt
+↳ Backup created @ refs/wt-backup/feature-staged (19192b8)
+↳ To recover in a new worktree, run wt switch --create --base 19192b89c76171cbb7280869c171e0064e0aebbc --no-hooks recovery/19192b8
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_force_with_untracked_files.snap b/tests/snapshots/integration__integration_tests__remove__remove_force_with_untracked_files.snap
index 9cb4da38c..598ac73ca 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_force_with_untracked_files.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_force_with_untracked_files.snap
@@ -62,4 +62,7 @@ exit_code: 0
----- stderr -----
◎ Removing feature-untracked worktree (--force) & branch in background (same commit as main, _)
▲ Discarding uncommitted changes (--force):
+  ?? .gitignore
  ?? devbox.lock
+↳ Backup created @ refs/wt-backup/feature-untracked (3eaf726)
+↳ To recover in a new worktree, run wt switch --create --base 3eaf726b4efd2dff18ca2b9a05a7adaab929d312 --no-hooks recovery/3eaf726