致命的:' / myorg / myrepo'似乎不是一个git存储库

时间:2015-09-04 23:25:51

标签: git ssh

我在尝试克隆git存储库时遇到此错误:

[myuser@mymachine ~]$ git clone git+ssh://git@gitmachine/myorg/myrepo
Cloning into 'myrepo'...
fatal: '/myorg/myrepo' does not appear to be a git repository
fatal: Could not read from remote repository.

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

我知道存储库存在,因为此命令有效:

[myuser@mymachine ~]$ git clone git@gitmachine:myorg/myrepo
Cloning into 'myrepo'...
remote: Counting objects: 2986, done.
remote: Compressing objects:  88% (1972/2238)
....

我认为问题是第一个命令正在进行git搜索repo /myorg/myrepo而不是myorg/myrepo,因为如果我将额外的/添加到第二个命令,它就会停止工作并显示与第一个完全相同的错误消息:

[myuser@mymachine ~]$ git clone git@gitmachine:/myorg/myrepo
Cloning into 'myrepo'...
fatal: '/myorg/myrepo' does not appear to be a git repository
fatal: Could not read from remote repository.

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

如何在此存储库中使用SSH语法?

(我认为我需要SSH语法的原因是因为我尝试使用GIT设置端口转发)

1 个答案:

答案 0 :(得分:0)

这也适用于git主目录的相对路径:

git clone git+ssh://git@gitmachine:myorg/myrepo

git clone git+ssh://git@gitmachine/~git/myorg/myrepo

通过放置绝对路径,你不会破坏任何东西。

了解更多信息

您可以讨论git-clone(1)的手册页:

  

GIT网址

     

通常,URL包含有关传输协议,远程服务器地址和存储库路径的信息。根据传输协议,可能缺少某些信息。

     

Git支持ssh,git,http和https协议(此外,ftp和ftps可用于获取,rsync可用于获取和推送,但这些效率低且不推荐使用;请勿使用它们)。

     

本机传输(即git:// URL)不进行身份验证,在不安全的网络上应谨慎使用。

     

以下语法可以与它们一起使用:

     
      
  • ssh://[user@]host.xz[:port]/path/to/repo.git/< -
  •   
  • git://host.xz[:port]/path/to/repo.git/
  •   
  • http[s]://host.xz[:port]/path/to/repo.git/
  •   
  • ftp[s]://host.xz[:port]/path/to/repo.git/
  •   
  • rsync://host.xz/path/to/repo.git/
  •   
     

另一种类似scp的语法也可以与ssh协议一起使用:

     
      
  • [user@]host.xz:path/to/repo.git/< -
  •   
     

只有在第一个冒号之前没有斜杠时才会识别此语法。这有助于区分包含冒号的本地路径。例如,本地路径foo:bar可以指定为绝对路径或./foo:bar,以避免被误解为ssh url。

     

ssh和git协议还支持〜用户名扩展:

     
      
  • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/**< -
  •   
  • git://host.xz[:port]/~[user]/path/to/repo.git/
  •   
  • [user@]host.xz:/~[user]/path/to/repo.git/
  •   
相关问题