I\'ve looked at all of the other ambiguous refname questions and none of them seem to help. Why am I getting this warning?
$ git checkout master
warning: ref
TL;DR: save and delete the tag, as Ashutosh Jindal comments (see "Rename a tag in git?"):
git tag tag-master master
git tag -d master
Original answer:
Most of the sources I see (like this FAQ) point to the same cause:
When you try to checkout a local branch, you get a
warning: refname 'branch-name' is ambiguous
This can happen if you've created a local branch with the same name as a remote tag.
Git should be checking out your local branch, but instead it's trying to checkout the tag, and it gets confused.The initial import of several trees were problematic, since they contained identically named branches and tags. We have since addressed a lot of these issues, by renaming away the tags.
In your case, you don't have a remote, but local tags named like your branch could be enough.
The ambiguity is specified in gitrevision
, e.g. master, heads/master, refs/heads/masterA symbolic ref name. E.g.
mastertypically means the commit object referenced byrefs/heads/master.
If you happen to have bothheads/masterandtags/master, you can explicitly sayheads/masterto tell git which one you mean.
When ambiguous, ais disambiguated by taking the first match in the following rules:If
$GIT_DIR/exists, that is what you mean (this is usually useful only forHEAD,FETCH_HEAD,ORIG_HEAD,MERGE_HEADandCHERRY_PICK_HEAD);
- otherwise,
refs/if it exists;- otherwise,
refs/tags/if it exists;- otherwise,
refs/heads/if it exists;- otherwise,
refs/remotes/if it exists;- otherwise,
refs/remotes/if it exists./HEAD
So check where master can be found in your repo.
And git checkout heads/master would always work.
Warning: by default, this would checkout the branch in a DETACHED HEAD mode. See "Why does git checkout with explicit 'refs/heads/branch' give detached HEAD?".
To avoid that, and still use an unambiguous ref, type:
git checkout -B master heads/master