TL; DR: save and delete tag, Ashutosh Jindal comments (see " Rename tag to git? "):
git tag tag-master master git tag -d master
Original answer:
Most of the sources that I see (for example, this FAQ ) point to the same reason:
When you try to check the local branch, you get
warning: refname 'branch-name' is ambiguous
This can happen if you create a local branch with the same name as the remote tag .
Git should check your local branch, but instead, it tries to check the tag, and it gets confused.
The initial import of several trees was problematic because they contained the same named branches and tags. Since then, we have addressed many of these issues: rename tags .
In your case, you do not have remote, but local tags named as your branch may be enough.
Uncertainty specified in gitrevision
<refname> , i.e. master , heads/master , refs/heads/master
The symbolic name of the link. For example. master usually means the commit object referenced by refs/heads/master .
If you have both heads/master and tags/master , you can explicitly say heads/master to tell Git what you mean.
With ambiguity, a <refname> is ambiguously eliminated by accepting the first match in the following rules:
If $GIT_DIR/<refname> exists, this is what you mean (usually only useful for HEAD , FETCH_HEAD , ORIG_HEAD , MERGE_HEAD and CHERRY_PICK_HEAD );
- otherwise
refs/<refname> if it exists; - otherwise
refs/tags/<refname> if it exists; - otherwise
refs/heads/<refname> if it exists; - otherwise
refs/remotes/<refname> if it exists; - otherwise
refs/remotes/<refname>/HEAD if one exists.
So check where master can be found in your repo.
And git checkout heads/master will always work.
Warning: by default, this will check the branch in DETACHED HEAD mode. See " Why git checkout with explicit" refs/heads/branch "give a separate HEAD? "
To avoid this and still use a single-valued ref, enter:
git checkout -B master heads/master