git通过ssh克隆 [英] git clone through ssh

查看:126
本文介绍了git通过ssh克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ 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 

这一次的答案是:


fatal:目标路径'ssh:// user @ server:/GitRepos/myproject.git'已经存在并且不是空目录。


但我看到路径为空。

这里发生了什么?

解决方案

这可能与问题直接无关;但是我犯了一个错误,我在OP中看到的是URL规范 ssh:// user @ server:/GitRepos/myproject.git - 即你在表示绝对路径后,它们都有冒号和正斜杠 /


$ b

然后我找到了 Git clone,ssh:Could not解析主机名--git,development - Nicolas Kuttler (因为这是我得到的错误,在 git 版本1.7.9.5中),注意到:


我最初使用的命令的问题是我试图使用类似scp的语法。


...这也是我的问题!因此,基本上在 git 中使用 ssh ,您可以使用




  • ssh://username@host.xz/absolute/path/to/repo.git/ - 只是绝对路径的正斜杠服务器

  • username@host.xz: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 :

fatal: destination path 'ssh://user@server:/GitRepos/myproject.git' already exists and is not an empty directory.

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:

The problem with the command I used initially was that I tried to use an scp-like syntax.

... which was also my problem! So basically in git with ssh, you either use

  • ssh://username@host.xz/absolute/path/to/repo.git/ - just a forward slash for absolute path on server
  • username@host.xz: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克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆