From: Yoichi NAKAYAMA via GitGitGadget Date: Tue, 25 Aug 2026 21:04:31 GMT Subject: [PATCH v8 0/4] worktree add: improve message for ambiguous remote branch name Message-ID: In-Reply-To: 'git worktree add ../foo-dir bar-topic' fails to dwim when there are multiple remote branches with name `bar-topic'. But it doesn't display meaningful message as 'git checkout bar-topic' does under the same situation. We improve this by adding advice and modify the error message for worktree add. By Junio's suggestion, we include matched remote names in the advice. It is applied to checkout, too. We also fix the behavior of --guess-remote when there are multiple matches. Changes from the previous patch: * add another commit to fix the behavior of --guess-remote Yoichi NAKAYAMA (4): checkout: extract function to display advice for ambiguous remotes checkout: improve message for ambiguous remote branch name worktree add: improve message for ambiguous remote branch name worktree add: treat multiple matches with --guess-remote as an error Documentation/config/worktree.adoc | 5 +- Documentation/git-worktree.adoc | 4 +- builtin/checkout.c | 76 ++++++++++++++++++------------ builtin/worktree.c | 57 +++++++++++++++++++--- checkout.c | 14 +++++- checkout.h | 5 +- t/t2400-worktree-add.sh | 17 ++++++- 7 files changed, 134 insertions(+), 44 deletions(-) base-commit: dea0ea3582e6980ddbc1173cc8e3e9f9db91cde0 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2197%2Fyoichi%2Fimprove-worktree-add-error-message-v8 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2197/yoichi/improve-worktree-add-error-message-v8 Pull-Request: https://github.com/gitgitgadget/git/pull/2197 Range-diff vs v7: 1: e3f7d88520 = 1: e3f7d88520 checkout: extract function to display advice for ambiguous remotes 2: 89c0f4d303 = 2: 89c0f4d303 checkout: improve message for ambiguous remote branch name 3: 095a5796d4 = 3: 095a5796d4 worktree add: improve message for ambiguous remote branch name -: ---------- > 4: 927856e0a0 worktree add: treat multiple matches with --guess-remote as an error -- gitgitgadget