问题描述
$ cd myproject
$ git init
$ git add。
$ git commit
我希望在另一台机器上创建裸露克隆: p>
$ cd ..
$ git clone --bare myproject ssh:// user @ server:/ GitRepos / myproject。 git
我执行了克隆,但没有打印任何答案。
我登录到服务器计算机并试图查看文件的存储方式。路径/ GitRepos为空,所以我决定再次进行克隆:
$ git clone --bare myproject ssh:/ /user@server:/GitRepos/myproject.git
这一次的答案是:
但我看到路径为空。
这里发生了什么?
这可能与问题直接无关;但是我犯了一个错误,我在OP中看到的是URL规范 ssh:// user @ server:/GitRepos/myproject.git - 即你在表示绝对路径后,它们都有冒号:和正斜杠 / 。
$ b
然后我找到了(因为这是我得到的错误,在 git 版本1.7.9.5中),注意到:
...这也是我的问题!因此,基本上在 git 中使用 ssh ,您可以使用
- ssh://[email protected]/absolute/path/to/repo.git/ - 只是绝对路径的正斜杠服务器
- [email protected]:relative / path / to / repo.git / - 只是一个冒号在服务器上有相对路径的 ssh:// (相对于服务器上的 username 的主目录) li>
希望这有助于某人,
干杯!
I have a project on which I created a git repository:
$ cd myproject $ git init $ git add . $ git commit
I the wanted to create a bare clone on another machine:
$ cd .. $ git clone --bare myproject ssh://user@server:/GitRepos/myproject.git
I executed the clone but did not print any answer.I logged on to the server machine and tried to see how the files are stored. The path /GitRepos was empty, so I decided to do the clone again:
$ git clone --bare myproject ssh://user@server:/GitRepos/myproject.git
This time the answer was :
But I saw that the path was empty.
What's going on here ?
This is possibly unrelated directly to the question; but one mistake I just made myself, and I see in the OP, is the URL specification ssh://user@server:/GitRepos/myproject.git - namely, you have both a colon :, and a forward slash / after it signifying an absolute path.
I then found Git clone, ssh: Could not resolve hostname – git , development – Nicolas Kuttler (as that was the error I was getting, on git version 1.7.9.5), noting:
... which was also my problem! So basically in git with ssh, you either use
- ssh://[email protected]/absolute/path/to/repo.git/ - just a forward slash for absolute path on server
- [email protected]:relative/path/to/repo.git/ - just a colon (it mustn't have the ssh:// for relative path on server (relative to home dir of username on server machine)
Hope this helps someone,
Cheers!
这篇关于git通过ssh克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!