当前位置: 首页 > 知识库问答 >
问题:

git refname“origin/master”不明确

云韬
2023-03-14
$ git branch -a
* master
  remotes/git-svn
  remotes/origin/master
  remotes/trunk
$ git branch --set-upstream-to=origin/master master
warning: refname 'origin/master' is ambiguous.
fatal: Ambiguous object name: 'origin/master'.

我想删除一些远程主控分支,但主控引用仍然存在。如何删除它们才能将默认上游分支设置为origin/master

$ git show-ref master
cba97a58c99743c355b569bbf35636c8823c2d96 refs/heads/master
6726b4985107e2ddc7539f95e1a6aba536d35bc6 refs/origin/master
d83f025cd3800ed7acd76b2e52ae296e33f1cd07 refs/original/refs/heads/master
cba97a58c99743c355b569bbf35636c8823c2d96 refs/remotes/origin/master

共有1个答案

鲜于德业
2023-03-14

git branch-a的输出显示您有一个名为origin/master的远程跟踪分支。完全正常。

但是,git show-ref master的输出包含

6726b4985107e2ddc7539f95e1a6aba536d35bc6 refs/origin/master

这表明您很可能运行了类似以下低级命令的内容:

git update-ref refs/origin/master master
    null
git update-ref -d refs/origin/master
git branch --set-upstream-to=refs/remotes/origin/master master
$ cd ~/Desktop
$ git clone https://github.com/Jubobs/gitdags && cd gitdags

$ git update-ref refs/origin/master

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

$ git show-ref master
15b28ec22dfb072ff4369b35ef18df51bb55e900 refs/heads/master
15b28ec22dfb072ff4369b35ef18df51bb55e900 refs/origin/master
15b28ec22dfb072ff4369b35ef18df51bb55e900 refs/remotes/origin/HEAD
15b28ec22dfb072ff4369b35ef18df51bb55e900 refs/remotes/origin/master

$ git branch --set-upstream-to=origin/master master
warning: refname 'origin/master' is ambiguous.
fatal: Ambiguous object name: 'origin/master'.

$ git update-ref -d refs/origin/master
$ git branch --set-upstream-to=origin/master master
Branch master set up to track remote branch master from origin.
 类似资料: