![](/img/trans.png)
[英]Fail to use git pull “Couldn't find remote ref –-allow-unrelated-histories”
[英]git clone "you appear to have cloned an empty repository" but it's not empty, pull says "couldn't find remote ref master"
我正在尝试使用驱动器映射在两个 W10 系统上首次使用 git 2.37.1 设置一个香草新的独立存储库,但鉴于我的新手,我找不到任何适合我的情况的已回答问题。 :-) 抱歉格式搞砸了,我在代码前面做了 4 个空格,但大多数代码行由于某种原因忽略了这一点。
花了几个小时查看其他类似的问题,但他们似乎都说我试图克隆的远程存储库中没有提交,这是不正确的。 有很多提交。
我在 System1 上创建了一个 git 存储库,它可以工作。
git ls-tree --full-tree --name-only -r HEAD
显示我所有的文件(有很多提交)
git show HEAD
节目
commit 557...27d (HEAD -> master)
# and the diff between the latest and previous commit
和
git branch -a
节目
* master
没有分支,没有复杂性,什么都没有
我去 System2,并创建我的 repo 目录, cd 进入它,然后
git init
git remote add origin s:/cap2office # that's my mapped System1 repository)
git pull origin master
我得到: fatal: couldn't find remote ref master
git remote
我得到: origin
git branch -a
什么都不显示
git ls-remote
显示: From s:/cap2office
我也试过:
git clone s:/cap2office
它说
Cloning into 'cap2office'...
warning: You appear to have cloned an empty repository.
我知道我错过了一些微不足道的魔法命令,但无法弄清楚它是什么。
您不是在克隆存储库,而是在尝试克隆 git clone 的工作目录。
git 存储库存储在工作目录内的.git
文件夹中。
尝试这个:
git remote add origin s:/cap2office/.git
在系统 2 上,不要执行git init
然后执行git remote add
和git pull
,只需执行以下操作:
git clone s:/cap2office/.git
或者如果你在 Git Bash 中,有时冒号不起作用,所以你需要
git clone s/cap2office/.git
然后你可以cd
到它被克隆的文件夹并执行通常的git status
、 git checkout
、更改内容、提交和推送到远程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.