无法在本地存储库上进行git推送

时间:2012-12-11 15:25:50

标签: git

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

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

然后我按照命令

启动git守护进程
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存储库的哪一步。我采取的所有举措都没问题,或者缺乏配置git存储库的地方。

1 个答案:

答案 0 :(得分:4)

这告诉你的是,你的master存储库中没有origin分支,因为它是空的。因此,它无法找到您想要更新的分支,并且默认情况下它不会盲目地创建一个新的分支(如果它是一个拼写错误或其他东西)。您可能需要第一次使用git push -f origin master。在master中有origin分支后,正常git push应该可以正常工作。

或者,您可以先创建工作存储库,其中至少有一个提交,然后git clone --bare将其创建到您的git-daemon位置,但您需要删除{{1}您的裸存储库中的远程规范,您必须在工作存储库中手动添加(或重新克隆)。