简体   繁体   English

如何在另一台主机上 git clone 裸远程 git 存储库

[英]How to git clone bare remote git repository on another host

I have ubuntu running on a virtual box guest with IP address 192.168.0.92 and I can ping this computer from my host running Windows 7. I can also ping the other way from ubuntu to windows.我在 IP 地址为 192.168.0.92 的虚拟机上运行 ubuntu,我可以从运行 Windows 7 的主机 ping 这台计算机。我也可以从 ubuntu 以其他方式 ping 到 Windows。

In ubuntu I created a bare repository like this:在 ubuntu 中,我创建了一个像这样的裸仓库:

angus@angus-VirtualBox:~/Documents/Courses/oss/play$ git init --bare myexample.git
Initialised empty Git repository in /home/angus/Documents/Courses/oss/play/myexample.git/
angus@angus-VirtualBox:~/Documents/Courses/oss/play$ git daemon&
[1] 2790

On my Windows 7 host I ran these commands in git bash:在我的 Windows 7 主机上,我在 git bash 中运行了这些命令:

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ git clone 192.168.0.92:myexample.git
Cloning into 'myexample'...
ssh: connect to host 192.168.0.92 port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ git clone 192.168.0.92:myexample.git
Cloning into 'myexample'...
ssh: connect to host 192.168.0.92 port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ git clone 192.168.0.92:/home/angus/Documents/Courses/oss/myexample.git
Cloning into 'myexample'...
ssh: connect to host 192.168.0.92 port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

I saw the ssh error so thought I might have to specify the git protocol so tried:我看到了 ssh 错误,所以我想我可能必须指定 git 协议,所以尝试了:

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ git clone 
git://192.168.0.92/home/angus/Documents/Courses/oss/play/myexample.git/
Cloning into 'myexample'...
fatal: remote error: access denied or repository not exported: 
/home/angus/Documents/Courses/oss/myexample.git

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ git clone git://192.168.0.92:myexample.git
Cloning into 'myexample'...
fatal: No path specified. See 'man git-pull' for valid url syntax

What path do I need to specify in the clone command?我需要在克隆命令中指定什么路径? How can I get this working?我怎样才能让它工作?

You'll have to let git-daemon know it can serve your repo:你必须让git-daemon知道它可以为你的 repo 服务:

$ git init --bare myexample.git
$ git daemon --verbose --base-path=. --export-all &

Then on your client, clone the repo with:然后在您的客户端上,使用以下命令克隆存储库:

$ git clone git://192.168.0.92/myexample.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM