警告:远程HEAD指的是不存在的参考,无法结帐 [英] warning: remote HEAD refers to nonexistent ref, unable to checkout
问题描述
我有一个简单的git仓库叫做kiflea.git,我像这样克隆它:
git clone git://kipdola.be/kiflea.git
然后git告诉我:警告:远程HEAD引用不存在的引用,无法结帐。
是的,除了.git目录之外,地图中没有版本化的文件。
无论如何,我唯一需要做的事情是:
$ cd $ k $ $ b $ git checkout master
它起作用,所有文件都在那里。
但我认为克隆repo会自动检查master,所以到底发生了什么,我该如何解决它?
我注意到,在执行 git checkout master
位后,它会被添加到我的本地.git配置文件中:
[branchmaster]
remote = origin
merge = refs / heads / master
知道这个git仓库在过去曾经是一个svn仓库可能很有趣。
Ps:当浏览裸仓库使用gitweb,那里显然有一个 master
分支: http://kipdola.be/gitweb/?p=kiflea.git;a=summary
警告:远程HEAD引用不存在的引用,无法检出。
表示远程(裸)存储库在文件<$中包含分支引用c $ c> HEAD 即可s不匹配同一个存储库中的任何已发布分支。 请注意,警告仅意味着git没有执行结帐。克隆的存储库否则就好了。只要执行 这通常是因为该文件的默认内容( 这种情况的问题在于,Git不提供修改 remote 符号引用的方法,以便您使用Git托管提供程序实现的内容(例如,设置 - GitHub中的默认分支,如果您拥有管理员权限),或者您必须使用分支名称 解决此问题的一种方法是创建一个新的远程裸回购没有提交,然后做 This seems like a popular error for different causes. I've got a simple bare git repo called "kiflea.git", I clone it like this: Then git tells me: And yes, there are no versioned files in the map, except for the .git directory.
Anyway, the only thing I need to do is: And it works, all the files are there.
But I thought cloning a repo automatically checks out the master, so what is going on exactly, and how do I fix it? I have noticed that, after I do the It's probably interesting to know that this git repository used to be an svn repository in a distant past. Ps: when browsing the bare repository using gitweb, there clearly is a The Note that the warning only means that git didn't do checkout. The cloned repository is otherwise just fine. Just do This usually happens because the default contents for that file ( The problem with this situation is that Git does not provide a method for modifying remote symbolic refs so either you use something the Git hosting provider has implemented (e.g. Settings - Default branch in GitHub if you have admin rights) or you have to use branch name One way to hit this issue is to create a new remote bare repo with no commits and then do 这篇关于警告:远程HEAD指的是不存在的参考,无法结帐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! git branch -a
即可查看可能的分支并
.git / HEAD
或plain HEAD
为裸仓库)是 ref:refs / heads / master
这就是说如果有人要去克隆
这个存储库,他们应该默认克隆分支 refs / heads / master
。默认情况下,Git将创建没有 refs / heads /
前缀的本地分支(即默认情况下为 master
)。尝试 git help symbolic-ref
获取更多信息。
master
作为默认分支(因为这是该符号引用的默认值)。
git推名称的远程my-special-branch-name
这将导致裸仓库包含一个分支 my-special-branch-name
但是 HEAD
符号引用仍然包含指向的默认值,主
。因此,你会得到上述警告。git clone git://kipdola.be/kiflea.git
warning: remote HEAD refers to nonexistent ref, unable to checkout.
cd kiflea
git checkout master
git checkout master
bit, this gets added to my local .git config file:[branch "master"]
remote = origin
merge = refs/heads/master
master
branch there: http://kipdola.be/gitweb/?p=kiflea.git;a=summarywarning: remote HEAD refers to nonexistent ref, unable to checkout.
means that the remote (bare) repository contains branch reference in the file HEAD
that does not match any published branch in the same repository.git branch -a
to see possible branches and git checkout the-branch-you-want
to workaround the issue..git/HEAD
or plain HEAD
for bare repositories) is ref: refs/heads/master
which says that if somebody is going to clone
this repository, they should by default clone the branch refs/heads/master
. By default Git will create local branch without the refs/heads/
prefix (that is, master
by default). Try git help symbolic-ref
for more information.master
as the default branch (because that's the default value for that symbolic ref).git push name-of-the-remote my-special-branch-name
which will result in bare repository containing a single branch my-special-branch-name
but the HEAD
symbolic ref still contains the default value pointing to master
. As a result, you'll get the aforementioned warning.