Use __git to invoke "worktree list" in __git_complete_worktree_paths, to respect any "-C" and "--git-dir" options present on the command line. Signed-off-by: Rubén Justo <rjusto@xxxxxxxxx> --- I stumbled upon this in a situation like: $ git init /tmp/foo && cd /tmp/foo $ git worktree add --orphan foo_wt $ git init /tmp/bar && cd /tmp/bar $ git worktree add --orphan bar_wt $ cd /tmp/foo $ git -C /tmp/bar worktree remove <TAB> ... expecting /tmp/bar/wt, but ... $ git -C /tmp/bar worktree remove /tmp/foo_wt contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 444b3efa63..86e55dc67f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3571,7 +3571,7 @@ __git_complete_worktree_paths () # Generate completion reply from worktree list skipping the first # entry: it's the path of the main worktree, which can't be moved, # removed, locked, etc. - __gitcomp_nl "$(git worktree list --porcelain | + __gitcomp_nl "$(__git worktree list --porcelain | sed -n -e '2,$ s/^worktree //p')" } -- 2.44.0