1

我使用的 Git-1.7.11-preview20120710.exe。我创建了一个 git 存储库

cd "GIT scm/"
git init --bare shahed.git
cd shahed.git
git update-server-info

然后我通过以下命令启动 git daemon

git daemon --reuseaddr --base-path="E:/GIT scm/" --export-all --verbose --enable=receive-pack

然后我克隆git存储库如下

git clone git://localhost/shahed.git

Cloning into 'shahed'...
warning: You appear to have cloned an empty repository.

cd shahed
touch shahed.txt
touch shohel.txt
git add *.*
git commit -m 'ok'

[master (root-commit) 2062f1d] 'ok'
 0 files changed
 create mode 100644 shahed.txt
 create mode 100644 shohel.txt

git push

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date

虽然 git 守护进程控制台记录以下消息

[4044] Ready to rumble
[736] Connection from [::1]:50076
[736] Extended attributes (16 bytes) exist <host=localhost>
[736] Request upload-pack for '/shahed.git'
[4044] [736] Disconnected
[4860] Connection from [::1]:50079
[4860] Extended attributes (16 bytes) exist <host=localhost>
[4860] Request receive-pack for '/shahed.git'
[4860] fatal: The remote end hung up unexpectedly

但我无法 git push。有人告诉我我错过了创建 git 存储库的哪一步。我采取的所有举措都可以,或者配置git存储库的不足之处在哪里。

4

1 回答 1

4

master这告诉您的是,您的裸存储库中没有分支origin,因为它是空的。因此,它找不到您要更新的分支,并且默认情况下它不会盲目地创建一个新分支(以防它是一个错字什么的)。您可能需要git push -f origin master第一次使用。一旦有一个master分支origin,正常git push应该可以正常工作。

或者,您可以首先创建您的工作存储库,其中至少有一个提交,然后git clone --bare将其放入您的git-daemon位置,但是您随后会想要删除origin裸存储库中的远程规范,并且您必须手动添加它(或重新克隆)在您的工作存储库中。

于 2012-12-11T16:09:58.013 回答