git refname 'origin/master' is ambiguous

前端 未结 4 2143
遥遥无期
遥遥无期 2020-12-02 06:46

I have a git repository that is tracking several remote branches:

$ git branch -a
* master
  remotes/git-svn
  remotes/origin/master
  remotes/trunk
<         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 06:54

    I faced same problem few days ago where there were multiple references created of the same branch.

    Things i tried:

    > git show-ref (will give you the list of references, from the
    > references list you can check if there are multiple references created
    > for the branch you are working on or not.)
    

    If there are multiple references created then simply remove it

    rm .git/refs/heads/master
    

    After removing the references you can take the checkout of the branch from remote origin only if you have pushed something in it, otherwise you have to redo everything which you did in the branch

    git fetch origin
    git checkout origin/branchName
    

    This solution worked out for me in case of ambiguous branches.

提交回复
热议问题