【发布时间】:2015-03-07 16:04:38
【问题描述】:
我在我的服务器上创建了一个具有 http 访问权限的裸 git 存储库。在我使用的客户端上:
git init
git clone <URL>
touch 2.txt
git commit
git remote add origin <URL>
git push origin master
所有这些命令都可以正常工作。然后我想看看我的存储库是否有“2.txt” 我来自我使用的其他机器:
git init
git clone <URL>
git remote add origin <URL>
git pull origin master
我得到了:
Could't find remote ref master
Unexpected end of command stream
我尝试了其他变体:
git pull
我得到了:
Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched
我认为,问题是我在服务器上没有任何分支。我试图在服务器上创建分支主控,但什么也没有(mb coz 那是裸存储库) 我使用该指南创建对存储库的 http 访问: https://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt 我完成了步骤 1-2,然后开始在没有指导的情况下进行操作。 我想我错过了一些东西,我最初的推送是错误的,因为它没有创建一个分支,但我不知道如何处理它。 我是 git 新手,我真的希望你能帮助我。
【问题讨论】:
-
你不需要在
git clone之前运行git init。事实上,这几乎肯定会给你带来麻烦,因为你会得到“嵌套存储库”。 -
我很确定您的
git push origin master失败了。 -
git clone <URL>一个人就够了。它将初始化、添加远程以及从远程拉取。 -
如果您克隆一个存储库,它会自动将其分配为新存储库中的
origin,因此您也不需要add remote命令。不过我不确定它会导致这个问题。 -
你没有告诉我们一切。您的第一段代码不应该正常工作。请参阅下面的答案。
标签: git