I\'m trying to check out one of my local branches, named TEAM20-lab2-release. When I try to do this, I get an ambiguous refname error:
$ git branch TEAM20-l
I got the same error message when trying to set the upstream branch for a local branch.
cgd@flavia-cgd-mobi:~/Projects/reporter$ git status
On branch master
nothing to commit, working directory clean
cgd@flavia-cgd-mobi:~/Projects/reporter$ git branch --set-upstream-to gerrit/master master
warning: refname 'gerrit/master' is ambiguous.
fatal: Ambiguous object name: 'gerrit/master'.
cgd@flavia-cgd-mobi:~/Projects/reporter$ git remote -vv
gerrit ssh://cgd@gerrit.server:29418/reporter (fetch)
gerrit ssh://cgd@gerrit.server:29418/reporter (push)
cgd@flavia-cgd-mobi:~/Projects/reporter$ git branch -a
gerrit/master
* master
remotes/gerrit/master
cgd@flavia-cgd-mobi:~/Projects/reporter$ git branch -d gerrit/master
Deleted branch gerrit/master (was 1234567).
cgd@flavia-cgd-mobi:~/Projects/reporter$ git branch --set-upstream-to gerrit/master master
Branch master set up to track remote branch master from gerrit.
cgd@flavia-cgd-mobi:~/Projects/reporter$ git fetch
cgd@flavia-cgd-mobi:~/Projects/reporter$ git status
On branch master
Your branch is up-to-date with 'gerrit/master'.
nothing to commit, working directory clean
As you can see I somehow created a local branch called gerrit/master which caused the conflict since git could not decide whether to track the local branch or the remote one. Deleting the erroneous branch fixed the thing and made me happy again.