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

2 messages from 2017-02-27 to 2017-02-28. Participants: Alexander Grigoriev, Duy Nguyen.
Thread: https://gitlist.dev/t/45239

## Alexander Grigoriev, 2017-02-27 14:22

Subject: Bug: "git worktree add" Unable to checkout a branch with no local ref
Message-ID: <0E511C089BC341FBA9DC694C1CE770AE@daddy>
URL: https://gitlist.dev/e/0E511C089BC341FBA9DC694C1CE770AE%40daddy

```
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. 


```

## Duy Nguyen, 2017-02-28 09:15

Subject: Re: Bug: "git worktree add" Unable to checkout a branch with no local ref
Message-ID: <CACsJy8DQTi5s2BmHSkTTjVKZu+ToeVhywkZa2hzGtkzWo95LJw@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8DQTi5s2BmHSkTTjVKZu%2BToeVhywkZa2hzGtkzWo95LJw%40mail.gmail.com
In-Reply-To: <0E511C089BC341FBA9DC694C1CE770AE@daddy>

```
On Mon, Feb 27, 2017 at 9:22 PM, Alexander Grigoriev
<alegrigoriev@gmail.com> wrote:
> 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.
-- 
Duy

```
