What's the purpose of the colon in this git repository url?

做~自己de王妃 提交于 2019-12-12 08:21:11

问题


Please pardon my ignorance; I'm new to Git and not sure where better to look for an answer, but what's the purpose of the colon after 'example.com' in the following url (which points to a git repository on my mediatemple server)?

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


回答1:


This syntax is actually wrong, but it's a bit like the scp-style syntax that you can use in git URLs, where it separates the hostname from the path on that host. Your options for specifying git URLs are listed in the git clone documentation. In your case you probably want one of the following instead:

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

... or:

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

In either case, the username is serveradmin%example.com, the hostname is example.com and the path on that host is /home/45678/domains/git.example.com/html/example.git.




回答2:


It separates the hostname (of the server)from the path (to the repo) as explained here




回答3:


The colon is notation which indicates to git the string after defines the repository you wish to interact with.

edit: Well spotted

As we can see the remote add is as follows:

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

and your example is:

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

where 'name' is 'repo_name'

and URL is the big string

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

which is even more apparent when we see it has the ssh protocol definition at the beginning.

In a URL you can define the colon without the proceeding port value and the default port for that protocol is generally used as the port number which seems to be what is happening here.

Therefore markup for the question and mark up for harpo's comment



来源:https://stackoverflow.com/questions/5279624/whats-the-purpose-of-the-colon-in-this-git-repository-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!