简体   繁体   English

将具有非标准端口号的SSH存储库克隆到SourceTree

[英]Clone SSH repository with non-standard port number to SourceTree

I spent about 20 minutes messing around with this problem. 我花了大约20分钟来解决这个问题。

I was emailed an SSH address for a repository. 我收到了通过电子邮件发送的用于存储库的SSH地址的电子邮件。 Crucially it had a non-standard (ie not 22) port number: git@domain.com:1234/opt/git/repository.git 至关重要的是,它具有非标准(即不是22)端口号: git@domain.com:1234/opt/git/repository.git

I assumed I could just copy-paste that into SourceTree, but kept getting This is not a valid source path / URL error messages. 我以为我可以将其复制粘贴到SourceTree中,但是一直保持This is not a valid source path / URL错误消息。

When I took a closer look at the logs, the error was that it was looking for the path 1234/opt/git/repository.git on the server - it was treating the port number as part of the path. 当我仔细查看日志时,错误是它正在服务器上寻找路径1234/opt/git/repository.git它将端口号视为路径的一部分。 And obviously not finding the repo. 而且显然找不到仓库。

The solution was slightly weird: 解决方案有点奇怪:

  1. Use a path like ssh:// git@domain.com:1234 :/ opt/git/repository.git . 使用类似ssh:// git@domain.com:1234的路径:/ opt/git/repository.git Appending ssh:// , and adding a : after the port number seemed to successfully act as a delimiter, and the path /opt/git/repository.git was found (as expected) on the server. 在端口号似乎成功用作分隔符之后,在服务器上找到了/opt/git/repository.git路径(如预期的那样),在端口号之后添加ssh://并添加一个:
  2. Add the domain/port number to your config file (eg ~/.ssh/config ) so that it looks like this: 将域/端口号添加到您的配置文件 (例如~/.ssh/config )中,使其看起来像这样:

Host domain.com Port 1234

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM