Skip to content

Commit 89ec4f7

Browse files
max-sixtyclaude
andauthored
docs(remove): state that --force discards all uncommitted changes (#2869)
The FAQ and the `wt remove --force` help text said `--force` overrides the untracked-files check "for build artifacts". `--force` actually removes a dirty worktree including staged and modified *tracked* files, not just untracked ones (`test_remove_force_with_modified_files`, `test_remove_force_with_staged_files`). On a destructive command, that wording can lead users to consent to more data loss than they expected. Updates the `--force` arg help, the "Force flags" table and example in `src/cli/mod.rs`, and the FAQ to say `--force` discards staged, modified, and untracked files; the `help_remove_long` snapshot and the `remove.md` / `faq.md` doc and skill mirrors are regenerated to match. > _This was written by Claude Code on behalf of Maximilian Roos_ Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 39cfd80 commit 89ec4f7

6 files changed

Lines changed: 31 additions & 28 deletions

File tree

docs/content/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Worktrunk can delete **worktrees** and **branches**. Both have safeguards.
144144

145145
### Worktree removal
146146

147-
`wt remove` mirrors `git worktree remove`: it refuses to remove worktrees with uncommitted changes (staged, modified, or untracked files). The `--force` flag overrides the untracked-files check for build artifacts that weren't cleaned up.
147+
`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.
148148

149149
For worktrees containing precious ignored data (databases, caches, large assets), use `git worktree lock`:
150150

docs/content/remove.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ Worktrunk has two force flags for different situations:
5858

5959
| Flag | Scope | When to use |
6060
|------|-------|-------------|
61-
| `--force` (`-f`) | Worktree | Worktree has untracked files |
61+
| `--force` (`-f`) | Worktree | Worktree has uncommitted changes |
6262
| `--force-delete` (`-D`) | Branch | Branch has unmerged commits |
6363

64-
{{ terminal(cmd="wt remove feature --force # Remove worktree with untracked files|||wt remove feature -D # Delete unmerged branch|||wt remove feature --force -D # Both") }}
64+
{{ terminal(cmd="wt remove feature --force # Remove dirty worktree|||wt remove feature -D # Delete unmerged branch|||wt remove feature --force -D # Both") }}
6565

66-
Without `--force`, removal fails if the worktree contains untracked files. Without `--force-delete`, removal keeps branches with unmerged changes. Use `--no-delete-branch` to keep the branch regardless of merge status.
66+
Without `--force`, removal fails if the worktree has staged, modified, or untracked files. Without `--force-delete`, removal keeps branches with unmerged changes. Use `--no-delete-branch` to keep the branch regardless of merge status.
6767

6868
## Background removal
6969

@@ -110,8 +110,8 @@ Usage: <b><span class=c>wt remove</span></b> <span class=c>[OPTIONS]</span> <spa
110110
<b><span class=c>-f</span></b>, <b><span class=c>--force</span></b>
111111
Force worktree removal
112112

113-
Remove worktrees even if they contain untracked files (like build artifacts). Without this
114-
flag, removal fails if untracked files exist.
113+
Remove a dirty worktree, including staged, modified, and untracked files. Without this
114+
flag, removal fails if the worktree has any uncommitted changes.
115115

116116
<b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
117117
Print help (see a summary with &#39;-h&#39;)

skills/worktrunk/reference/faq.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

skills/worktrunk/reference/remove.md

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,9 @@ pub(crate) struct RemoveArgs {
430430

431431
/// Force worktree removal
432432
///
433-
/// Remove worktrees even if they contain untracked files (like build
434-
/// artifacts). Without this flag, removal fails if untracked files exist.
433+
/// Remove a dirty worktree, including staged, modified, and untracked
434+
/// files. Without this flag, removal fails if the worktree has any
435+
/// uncommitted changes.
435436
#[arg(short, long)]
436437
pub(crate) force: bool,
437438

@@ -992,16 +993,16 @@ Worktrunk has two force flags for different situations:
992993
993994
| Flag | Scope | When to use |
994995
|------|-------|-------------|
995-
| `--force` (`-f`) | Worktree | Worktree has untracked files |
996+
| `--force` (`-f`) | Worktree | Worktree has uncommitted changes |
996997
| `--force-delete` (`-D`) | Branch | Branch has unmerged commits |
997998
998999
```console
999-
$ wt remove feature --force # Remove worktree with untracked files
1000+
$ wt remove feature --force # Remove dirty worktree
10001001
$ wt remove feature -D # Delete unmerged branch
10011002
$ wt remove feature --force -D # Both
10021003
```
10031004
1004-
Without `--force`, removal fails if the worktree contains untracked files. Without `--force-delete`, removal keeps branches with unmerged changes. Use `--no-delete-branch` to keep the branch regardless of merge status.
1005+
Without `--force`, removal fails if the worktree has staged, modified, or untracked files. Without `--force-delete`, removal keeps branches with unmerged changes. Use `--no-delete-branch` to keep the branch regardless of merge status.
10051006
10061007
## Background removal
10071008

tests/snapshots/integration__integration_tests__help__help_remove_long.snap

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ info:
1111
GIT_EDITOR: ""
1212
LANG: C
1313
LC_ALL: C
14-
LLVM_PROFILE_FILE: /var/folders/v3/8k5q0_6j3_q6gl4h8czr66sh0000gn/T/wt-test-profraw/cov-%m_%p.profraw
14+
LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
1515
NO_COLOR: ""
1616
PSModulePath: ""
1717
RUST_LOG: warn
1818
SHELL: ""
1919
TERM: alacritty
20-
WORKTRUNK_APPROVALS_PATH: /nonexistent/wt/approvals.toml
21-
WORKTRUNK_CONFIG_PATH: /nonexistent/wt/config.toml
22-
WORKTRUNK_SYSTEM_CONFIG_PATH: /etc/xdg/worktrunk/config.toml
20+
WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
21+
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
22+
WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
2323
WORKTRUNK_TEST_BASH_INSTALLED: "0"
2424
WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
25+
WORKTRUNK_TEST_CODEX_INSTALLED: "0"
2526
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
2627
WORKTRUNK_TEST_EPOCH: "1735776000"
2728
WORKTRUNK_TEST_FISH_INSTALLED: "0"
29+
WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
2830
WORKTRUNK_TEST_NUSHELL_ENV: "0"
2931
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
3032
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
@@ -58,7 +60,7 @@ Usage: wt remove [OPTIONS] [BRANCHES]...
5860
-f, --force
5961
Force worktree removal
6062

61-
Remove worktrees even if they contain untracked files (like build artifacts). Without this flag, removal fails if untracked files exist.[0m
63+
Remove a dirty worktree, including staged, modified, and untracked files. Without this flag, removal fails if the worktree has any uncommitted changes.[0m
6264

6365
-h, --help
6466
Print help (see a summary with '-h')
@@ -136,16 +138,16 @@ Branches matching these conditions and with empty working trees are dimmed in [
136138

137139
Worktrunk has two force flags for different situations:
138140

139-
Flag Scope When to use
140-
─────────────────── ──────── ────────────────────────────
141-
[2m--force[0m ([2m-f[0m) Worktree Worktree has untracked files
142-
[2m--force-delete[0m ([2m-D[0m) Branch Branch has unmerged commits
141+
Flag Scope When to use
142+
─────────────────── ──────── ────────────────────────────────
143+
[2m--force[0m ([2m-f[0m) Worktree Worktree has uncommitted changes
144+
[2m--force-delete[0m ([2m-D[0m) Branch Branch has unmerged commits
143145

144-
[107m [0m [2m[0m[2m[34mwt[0m[2m remove feature [0m[2m[36m--force[0m[2m # Remove worktree with untracked files[0m[2m[0m
146+
[107m [0m [2m[0m[2m[34mwt[0m[2m remove feature [0m[2m[36m--force[0m[2m # Remove dirty worktree[0m[2m[0m
145147
  wt remove feature -D # Delete unmerged branch
146148
  wt remove feature --force -D # Both
147149

148-
Without [2m--force[0m, removal fails if the worktree contains untracked files. Without [2m--force-delete[0m, removal keeps branches with unmerged changes. Use [2m--no-delete-branch[0m to keep the branch regardless of merge status.
150+
Without [2m--force[0m, removal fails if the worktree has staged, modified, or untracked files. Without [2m--force-delete[0m, removal keeps branches with unmerged changes. Use [2m--no-delete-branch[0m to keep the branch regardless of merge status.
149151

150152
Background removal
151153

0 commit comments

Comments
 (0)