这个git存储库url中冒号的目的是什么?

时间:2011-03-11 23:49:39

标签: git colon

请原谅我的无知;我是Git的新手并且不确定哪里可以更好地寻找答案,但是在下面的url(指向我的mediatemple服务器上的git存储库)中的'example.com'之后冒号的目的是什么?

git remote add repo_name ssh://serveradmin%example.com@example.com:/home/45678/domains/git.example.com/html/example.git

3 个答案:

答案 0 :(得分:10)

这种语法实际上是错误的,但它有点像你可以在git URL中使用的scp样式语法,它将主机名与该主机上的路径分开。您在git clone documentation中列出了指定git URL的选项。在您的情况下,您可能需要以下其中一种:

 serveradmin%example.com@example.com:/home/45678/domains/git.example.com/html/example.git

......或:

 ssh://serveradmin%example.com@example.com/home/45678/domains/git.example.com/html/example.git

在任何一种情况下,用户名为serveradmin%example.com,主机名为example.com,该主机上的路径为/home/45678/domains/git.example.com/html/example.git

答案 1 :(得分:4)

它将主机名(服务器)与路径(到repo)分开,如here所述

答案 2 :(得分:0)

冒号是表示在定义要与之交互的存储库后git字符串的符号。

编辑:好看的

我们可以看到远程添加如下:

git remote add [-t <branch>] [-m <master>] [-f] [--tags|--no-tags] [--mirror] <name> <url>

你的例子是:

git remote add repo_name ssh://serveradmin%example.com@example.com:/home/45678/domains/git.example.com/html/example.git

其中'name'是'repo_name'

和URL是大字符串

SSH://serveradmin%example.com@example.com:/home/45678/domains/git.example.com/html/example.git

当我们看到它在开头有ssh协议定义时更为明显。

在URL中,您可以定义没有进程端口值的冒号,并且该协议的默认端口通常用作端口号,这似乎是这里发生的事情。

因此标记问题并标记harpo的评论