# git checkout with an ambiguous rev

2 messages from 2019-10-02 to 2019-10-02. Participants: Rohit Sarkar.
Thread: https://gitlist.dev/t/51956

## Rohit Sarkar, 2019-10-02 12:02

Subject: git checkout with an ambiguous rev
Message-ID: <20191002120213.GB5812@SARKAR>
URL: https://gitlist.dev/e/20191002120213.GB5812%40SARKAR

```
Hi,
I was looking into writing a patch for the issue [1] where if an user has
multiple remotes each with a remote tracking branch of the same name say
xyz, 'git checkout xyz' fails with "error: pathspec 'xyz' did not match any
file(s) known to git."

This can sort of be handled by setting checkout.defaultRemote so that
the ambiguity is removed. Although when checkout.defaultRemote is not
set or there are more than 2 remotes I think it would be helpful if git
gives a message listing out the possible revs instead of the pathspec
error. What do you guys think?

[1] : https://public-inbox.org/git/CACcTrKdzVCKUR8EfwhqBQR7vWzRqTLcwRJ_r-hx3VztD=xvNuQ@mail.gmail.com/

```

## Rohit Sarkar, 2019-10-02 13:28

Subject: Re: git checkout with an ambiguous rev
Message-ID: <20191002132832.GD5812@SARKAR>
URL: https://gitlist.dev/e/20191002132832.GD5812%40SARKAR
In-Reply-To: <20191002120213.GB5812@SARKAR>

```
On Wed, Oct 02, 2019 at 05:32:13PM +0530, Rohit Sarkar wrote:
> Hi,
> I was looking into writing a patch for the issue [1] where if an user has
> multiple remotes each with a remote tracking branch of the same name say
> xyz, 'git checkout xyz' fails with "error: pathspec 'xyz' did not match any
> file(s) known to git."
> 
> This can sort of be handled by setting checkout.defaultRemote so that
> the ambiguity is removed. Although when checkout.defaultRemote is not
> set or there are more than 2 remotes I think it would be helpful if git
> gives a message listing out the possible revs instead of the pathspec
> error. What do you guys think?
> 
> [1] : https://public-inbox.org/git/CACcTrKdzVCKUR8EfwhqBQR7vWzRqTLcwRJ_r-hx3VztD=xvNuQ@mail.gmail.com/

Nvm. This was already handled in https://github.com/git/git/commit/ad8d5104b42108851b082d895018655ad5f9e4f3
by Avar

Thanks,
Rohit

```
