(已经解决了,我正在为下一个人写这个)
我在一台计算机上运行git守护程序并尝试与另一台计算机同步。
在计算机A上,我跑了:
git daemon --reuseaddr --base-path=. --export-all --verbose
在电脑B上,我跑了:
git clone git://computerA/.git source # worked
cd source
git pull # worked
git push # failed with "fatal: The remote end hung up unexpectedly"
在计算机A上,守护程序输出为:
[5596] Connection from 127.0.0.1:2476
[5596] Extended attributes (16 bytes) exist <host=localhost>
[5596] Request receive-pack for '/.git'
[5596] 'receive-pack': service not enabled for './.git'
[5444] [5596] Disconnected (with error)
我要发布我发现的灵魂。如果您有更完整的答案,请继续添加。
答案 0 :(得分:56)
简单地运行
git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack
(在计算机A上,而不是原始的git daemon
命令),推送工作。
请注意,您必须运行
git reset --hard
计算机A上的使其“看到”计算机B的更改。
执行硬重置的问题在于它会覆盖您在计算机A上进行的任何本地更改。
最终我意识到拥有一个没有任何文件的单独存储库(bare clone)会更有意义,然后让计算机B推送到它,计算机A从中推出。这样它可以双向工作并以平滑的方式合并所有更改。你甚至可以有两个裸克隆,每台计算机一个,以及它们之间的推拉。
答案 1 :(得分:20)
我遇到了这个错误,但对于那些使用git-http-backend的人来说,解决方案似乎有所不同。 (git push / pull / clone over http而不是ssh或git)
这必须在远程服务器上完成,最好在创建时完成。 (如果repo已存在/正在使用,则最后一行可以独立运行)
$ mkdir eddies # MAKE folder for repo
$ chown -R eddie:websrv eddies/ #ensure apache (webserver) can access it
$ cd eddies/
$ git --bare init --shared
Initialized empty shared Git repository in /var/git/eddies/
$ ls
branches config description HEAD hooks info objects refs
$ git config --file config http.receivepack true
答案 2 :(得分:4)
我在使用git reset时遇到了一些问题 - 硬件,所以这是我的替代解决方案。
在本地克隆的回购中创建一个分支
git checkout -b my_new_branch
远程源repo上的启用receive-pack
服务
git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack
将新分支推送到远程源
git push origin my_new_branch
将原点上的新分支与
合并git merge my_new_branch