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

Md *_*ain 1 git

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

cd "GIT scm/"
git init --bare shahed.git
cd shahed.git
git update-server-info
Run Code Online (Sandbox Code Playgroud)

然后我通过以下命令启动 git 守护进程

git daemon --reuseaddr --base-path="E:/GIT scm/" --export-all --verbose --enable=receive-pack
Run Code Online (Sandbox Code Playgroud)

然后我克隆 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
Run Code Online (Sandbox Code Playgroud)

当 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
Run Code Online (Sandbox Code Playgroud)

但我无法 git Push。有人告诉我创建 git 存储库时我错过了哪一步。都是我主动的,还是配置git仓库的不足在哪里。

twa*_*erg 5

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

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