49

I am getting this error when trying to create a remote tracking branch

git co -b release_2.6 origin/release_2.6 warning: refname 'origin/release_2.6' is ambiguous. warning: refname 'origin/release_2.6' is ambiguous. fatal: Ambiguous object name: 'origin/release_2.6'. 

I only have these two refs defined with release_2.6

git show-ref | grep "release_2.6" a71b2da1526f73862464a23aceaa1939a8b1ace2 refs/heads/origin/release_2.6 ed1399936a8cc4cd2feed1851123af861b0ff093 refs/remotes/origin/release_2.6 

Does anyone know what this error means?

Cheers

5 Answers 5

87

If something can be found in both refs/heads/ and refs/remotes/ then this is ambiguous. You have local branch origin/release_2.6 and remote tracking branch release_2.6 for remote origin. Don't think you are supposed to have a refs/heads/origin/release_2.6 branch though. Anyway, you can specify full reference name to resolve ambiguity:

git co -b release_2.6 refs/remotes/origin/release_2.6 
Sign up to request clarification or add additional context in comments.

3 Comments

The full ref search path is described in [ git-rev-parse(1) in the section “Specifying Revisions”](kernel.org/pub/software/scm/git/docs/…), under the bullet starting “A symbolic ref name. …”.
Yes i think I added the origin/release_2.6 branch accidentally but did not see it in the list. I deleted that local branch and then it all worked. Thank you!
Had the same problem when trying to do git branch --set-upstream-to=.... Adding refs/remotes/origin instead of simply origin/ worked :) .
15

I had similar error when I created a remote branch using git-svn. I had the remote branch and the local branch with same name. You can rename the local branch using
git branch -m old_branch new_name
This will just rename the local branch without changing the remote branch.

Shravan

Comments

9

For me, it was just a dumb mistake. I accidentally created a branch named like the remote, like in this case I had a local branch like origin/release_2.6 :)

Comments

4

I had a similar error when I cloned an SVN repository with git-svn, but I had no "origin" in either path. I ended up with the following refs:

 0e4b5116f69200ea0d7a2ff9f0fa15630d02b153 refs/heads/development 0ef5969f7ee44b16817053bfe146c499be5f77b7 refs/remotes/development 

and I was unable to branch; when I tried I would get the "ambiguous object name" error. My error was that when I did the original git svn clone, I did not specify a --prefix; the correct form was

git svn clone --prefix origin/ --stdlayout xxxx 

and then I ended up with refs/remotes/origin/development, etc. and there was no problem branching. According to the man page, you must have the trailing slash on the prefix.

Liam

Comments

4

I got this error because I had a branch "develop" and a tag called "develop".

$ git tag develop master staging v0.0.1-test v0.0.11 

Deleting both the local tag and remote tag matching the branch name worked for me.

$ git tag -d develop $ git push origin :refs/tags/develop 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.