git 警告:refname 'HEAD' 不明确
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1692892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
warning: refname 'HEAD' is ambiguous
提问by dagda1
I am new to Git and I seem to have one branch too many if I execute the following command:
我是 Git 的新手,如果我执行以下命令,我似乎有一个分支太多:
warning: refname 'HEAD' is ambiguous.
I get the following output:
我得到以下输出:
warning: refname 'HEAD' is ambiguous.
From github.com:dagda1/hornget
* branch master -> FETCH_HEAD
warning: refname 'HEAD' is ambiguous.
warning: refname 'HEAD' is ambiguous.
If I execute git branch -a
如果我执行 git branch -a
I get the following:
我得到以下信息:
HEAD
* master
remotes/emmekappa/master
remotes/origin/HEAD -> origin/master
remotes/origin/master
I am confused by the remotes/origin/HEAD -> origin/master
.
我对remotes/origin/HEAD -> origin/master
.
What is this and how can I get rid of the ambiguous branch.
这是什么以及如何摆脱模棱两可的分支。
I got to this stage by performing a merge where I think I added the ambiguous branch.
我通过执行合并进入了这个阶段,我认为我添加了不明确的分支。
回答by u0b34a0f6ae
The problem is that you have a branch called HEAD
which is absolutely dangerous, since that's the symbolic name for whatever branch is the currentbranch.
问题是你有一个HEAD
绝对危险的分支,因为它是当前分支的任何分支的符号名称。
Rename it:
重命名:
git branch -m HEAD newbranch
then you can examine it and decide what to do (delete it, or save under a descriptive branch name)
然后你可以检查它并决定做什么(删除它,或保存在一个描述性的分支名称下)
(The origin/HEAD
remote branch is not a problem)
(origin/HEAD
远程分支没有问题)
回答by Josiah
Also, this will delete the branch, if you just don't want it.
此外,如果您不想要它,这将删除分支。
git branch -d HEAD
Use a capital -D
to force the deletion:
使用大写-D
强制删除:
git branch -D HEAD
回答by Bengt
If you have created a tag named HEAD
using...
如果您创建了一个名为HEAD
using的标签...
git tag HEAD
...you can just delete that tag using:
...您可以使用以下方法删除该标签:
git tag -d HEAD
See this case: kerneltrap.org/git-tag HEAD
请参阅此案例:kerneltrap.org/git-tag HEAD
回答by stacksonstacksonstacks
This means that you have a branch named "head". I had the same issue, I solved by doing the following command.
这意味着您有一个名为“head”的分支。我有同样的问题,我通过执行以下命令解决了。
git branch -d head
回答by Darshan
Check references available in your git repository. You will observe two HEAD in your repository. This makes your branch with refname HEAD ambiguous.
检查 git 存储库中可用的引用。您将在存储库中观察到两个 HEAD。这使您的 refname HEAD 分支不明确。
git show-ref
Solution:
解决方案:
Rename the branch
git branch -m HEAD <new_branch_name>
OR
Delete the branch
git branch -d HEAD
重命名分支
git branch -m HEAD <new_branch_name>
或者
删除分支
git branch -d HEAD