]> git.ipfire.org Git - thirdparty/git.git/commitdiff
worktree: clarify that --expire only affects missing worktrees
authorSam Bostock <sam.bostock@shopify.com>
Wed, 28 Jan 2026 05:39:45 +0000 (05:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Jan 2026 23:25:33 +0000 (15:25 -0800)
The --expire option for "git worktree list" and "git worktree prune"
only affects worktrees whose working directory path no longer exists.
The help text did not make this clear, and the documentation
inconsistently used "unused" for prune but "missing" for list.

Update the help text and documentation to consistently describe these
as "missing worktrees", and use "prune" instead of "expire" when
describing the effect on missing worktrees since the terminology is
clearer.

While at it, expand the description of the "prune" subcommand itself
to better explain what it does and when to use it, as suggested by
Junio.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Sam Bostock <sam@sambostock.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-worktree.adoc
builtin/worktree.c

index f272f797837f454ea286cc9939929d6d42c8d6a8..22ef37ec0283c025b6eb7760d99837eb4680d469 100644 (file)
@@ -131,7 +131,13 @@ with linked worktrees if you move the main worktree manually.)
 
 `prune`::
 
-Prune worktree information in `$GIT_DIR/worktrees`.
+Remove worktree information in `$GIT_DIR/worktrees` for worktrees
+whose working trees are missing.  Useful after manually removing
+a working tree that is no longer needed (but use "git worktree
+remove" next time you want to do so).  Also, if you _moved_ a
+working tree elsewhere causing the worktree information to become
+dangling, see "git worktree repair" to reconnect the worktree to
+the new working tree location.
 
 `remove`::
 
@@ -271,7 +277,7 @@ mismatch, even if the links are correct.
 With `list`, output additional information about worktrees (see below).
 
 `--expire <time>`::
-       With `prune`, only expire unused worktrees older than _<time>_.
+       With `prune`, only prune missing worktrees if older than _<time>_.
 +
 With `list`, annotate missing worktrees as prunable if they are older than
 _<time>_.
index 812774a5ca992c5523116811239bb5a2f505f677..2b84028fea13b9c64a5bdf17ad15f3c8c57e2617 100644 (file)
@@ -252,7 +252,7 @@ static int prune(int ac, const char **av, const char *prefix,
                OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
                OPT__VERBOSE(&verbose, N_("report pruned working trees")),
                OPT_EXPIRY_DATE(0, "expire", &expire,
-                               N_("expire working trees older than <time>")),
+                               N_("prune missing working trees older than <time>")),
                OPT_END()
        };
 
@@ -1063,7 +1063,7 @@ static int list(int ac, const char **av, const char *prefix,
                OPT_BOOL(0, "porcelain", &porcelain, N_("machine-readable output")),
                OPT__VERBOSE(&verbose, N_("show extended annotations and reasons, if available")),
                OPT_EXPIRY_DATE(0, "expire", &expire,
-                               N_("add 'prunable' annotation to worktrees older than <time>")),
+                               N_("add 'prunable' annotation to missing worktrees older than <time>")),
                OPT_SET_INT('z', NULL, &line_terminator,
                            N_("terminate records with a NUL character"), '\0'),
                OPT_END()