'receive-pack':未为 './.git' 启用服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/792611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'receive-pack': service not enabled for './.git'
提问by itsadok
(Solved already, I'm writing this for the next guy)
(已经解决了,我正在为下一个人写这个)
I was running git daemon on one computer and tried synchronizing with another.
我在一台计算机上运行 git daemon 并尝试与另一台计算机同步。
On computer A, I ran:
在计算机 A 上,我运行:
git daemon --reuseaddr --base-path=. --export-all --verbose
On computer B, I ran:
在计算机 B 上,我运行:
git clone git://computerA/.git source # worked
cd source
git pull # worked
git push # failed with "fatal: The remote end hung up unexpectedly"
On computer A, the daemon output is:
在计算机 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)
I'm going to post the soultion I found. If you have a more complete answer, please go ahead and add it.
我要发布我找到的灵魂。如果您有更完整的答案,请继续添加。
回答by itsadok
Simply run
只需运行
git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack
(on computer A, instead of the original git daemon
command), and the push works.
(在计算机 A 上,而不是原始git daemon
命令),并且推送有效。
Note that you have to then run
请注意,您必须然后运行
git reset --hard
on computer A to make it "see" the changes from computer B.
在计算机 A 上使其“看到”来自计算机 B 的更改。
Post Script
发布脚本
The problem with doing a hard reset is that it overwrites whatever local changes you had on computer A.
进行硬重置的问题在于它会覆盖您在计算机 A 上所做的任何本地更改。
Eventually I realized it would make much more sense to have a separate repository (a bare clone) that doesn't have any files in it, then have computer B push to it and computer A pull from it. This way it can work both ways and merge all the changes in a smooth fashion. You can even have two bare clones, one on each computer, and push-pull between them.
最终我意识到拥有一个没有任何文件的单独存储库(一个裸克隆)会更有意义,然后让计算机 B 推送到它,计算机 A 从中提取。通过这种方式,它可以双向工作并以平滑的方式合并所有更改。您甚至可以拥有两个裸克隆,每台计算机上一个,并在它们之间进行推拉。
回答by Eddie
I encountered this error, but the solution seems different for those using git-http-backend. (git push/pull/clone over http instead of ssh or git)
我遇到了这个错误,但对于那些使用 git-http-backend 的人来说,解决方案似乎有所不同。(git push/pull/clone over http 而不是 ssh 或 git)
This must be done on the remote server, and is best done on creation. (last line can be run independently if repo already exists / is in use)
这必须在远程服务器上完成,最好在创建时完成。 (如果 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
回答by Benjamin Udink ten Cate
I have some issue with the git reset --hard so here is my alternative solution.
我对 git reset --hard 有一些问题,所以这是我的替代解决方案。
On the local cloned repo make a branch
在本地克隆的 repo 上创建一个分支
git checkout -b my_new_branch
on the remote origin repo enable the receive-pack
service
在远程源仓库上启用receive-pack
服务
git daemon --reuseaddr --base-path=. --export-all --verbose --enable=receive-pack
push the new branch to remote origin
将新分支推送到远程源
git push origin my_new_branch
merge the new branch on origin with
将原点上的新分支与
git merge my_new_branch