2

I am getting the following Ambiguous warning and not able to switch the branch, please help me to fix this

maradhak@WW720L102019A /c/myProj (mylocalbranch1)
$ git checkout -b mylocalbranch2 origin/sprint_20_master


warning: refname 'origin/sprint_20_master' is ambiguous.
Checking out files: 100% (535/535), done.
warning: refname 'origin/sprint_20_master' is ambiguous.
fatal: Ambiguous object name: 'origin/sprint_20_master'.

===>$ git branch -a, please find the output below

  master
* mylocalbranch1
  origin/sprint_20_master
  sampleapp
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/sampleapp
  remotes/origin/sprint20_jothi
  remotes/origin/sprint20mani
  remotes/origin/sprint_20_master

maradhak@WW720L102019A /c/myProj (mylocalbranch1)

===>$ git ls-remote . please find the output below

37aaf00bf238cc520307bfc51c2148f95908e086        HEAD
e42e61debb97f8dad54e3f825d9dd2fe44afef52        refs/heads/master
37aaf00bf238cc520307bfc51c2148f95908e086        refs/heads/mylocalbranch1
f346e6260f4c0166883e7dfba927f069d74a2c31        refs/heads/origin/sprint_20_master
f346e6260f4c0166883e7dfba927f069d74a2c31        refs/heads/sampleapp
e42e61debb97f8dad54e3f825d9dd2fe44afef52        refs/remotes/origin/HEAD
e42e61debb97f8dad54e3f825d9dd2fe44afef52        refs/remotes/origin/master
f346e6260f4c0166883e7dfba927f069d74a2c31        refs/remotes/origin/sampleapp
fb4faac845d7955b99e5345bad2c86c2f7187810        refs/remotes/origin/sprint20_jothi
37aaf00bf238cc520307bfc51c2148f95908e086        refs/remotes/origin/sprint20mani
36a77aeeef61ce744455f2406427d2e2ceb774ba        refs/remotes/origin/sprint_20_master

maradhak@WW720L102019A /c/myProj (mylocalbranch1)

===>$ git show-ref, please find the output below

e42e61debb97f8dad54e3f825d9dd2fe44afef52 refs/heads/master
37aaf00bf238cc520307bfc51c2148f95908e086 refs/heads/mylocalbranch1
f346e6260f4c0166883e7dfba927f069d74a2c31 refs/heads/origin/sprint_20_master
f346e6260f4c0166883e7dfba927f069d74a2c31 refs/heads/sampleapp
e42e61debb97f8dad54e3f825d9dd2fe44afef52 refs/remotes/origin/HEAD
e42e61debb97f8dad54e3f825d9dd2fe44afef52 refs/remotes/origin/master
f346e6260f4c0166883e7dfba927f069d74a2c31 refs/remotes/origin/sampleapp
fb4faac845d7955b99e5345bad2c86c2f7187810 refs/remotes/origin/sprint20_jothi
37aaf00bf238cc520307bfc51c2148f95908e086 refs/remotes/origin/sprint20mani
36a77aeeef61ce744455f2406427d2e2ceb774ba refs/remotes/origin/sprint_20_master
Manivannan
  • 3,074
  • 3
  • 21
  • 32

1 Answers1

5

Here is your problem:

f346e6260f4c0166883e7dfba927f069d74a2c31        refs/heads/origin/sprint_20_master
36a77aeeef61ce744455f2406427d2e2ceb774ba        refs/remotes/origin/sprint_20_master

You managed to construct a local branch called origin/sprint_20_master and also have the one that belongs to the remote. Git cannot distinguish which one you want to use as the base for your new branch. I'm assuming that you don't want the local version. You can delete it with:

git update-ref -m "remove ambiguous ref" -d refs/heads/origin/sprint_20_master
John Szakmeister
  • 44,691
  • 9
  • 89
  • 79