Skip to contentSkip to conversation

Bug: "git worktree add" Unable to checkout a branch with no local ref

DISCUSSION Alexander Grigoriev 2 participants 2 messages Feb 27, 2017 – Feb 28, 2017

lore
Share & tools
lore
#0 lore raw

git version 2.10.2.windows.1:
If a remote branch has never been checked out locally (its ref only exists in remotes/<remote>/ directory), "git worktree add" command is unable to check it out by its normal short name (not prefixed by remotes/<remote>), while "git checkout" command has been able to handle such a branch and properly convert it to a local branch.

#1 lore raw
Quoted 6 lines · Alexander Grigoriev

git version 2.10.2.windows.1:
If a remote branch has never been checked out locally (its ref only exists in remotes/<remote>/ directory), "git worktree add" command is unable to check it out by its normal short name (not prefixed by remotes/<remote>), while "git checkout" command has been able to handle such a branch and properly convert it to a local branch.

We call that "dwim" (do what I mean). Unfortunately "git worktree add" does not support it.

In the early prototype, "git worktree" called "git checkout" underneath and something like that should have worked. But I don't remember if the dwim came up when we decided not to let "git worktree" run "git checkout". And since dwim thing is checkout thing, the feature is gone from "git worktree add".

Anyway, I think patches are welcome.

Signature · 1 line
Duy