git克隆需要ssh://协议时,它可能不应该? [英] git clone requires ssh:// protocol when perhaps it shouldn't?

查看:104
本文介绍了git克隆需要ssh://协议时,它可能不应该?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个同事有一个远程git回购,我想克隆,他提供了一个git@his.server.com网址:443 / repo.git。在这种情况下,ssh在端口443上列出。



我尝试通过执行克隆 git clone git@his.server.com:443 / repo.git 但操作超时。我曾经认为git默认使用ssh作为协议,我不知道为什么这样做不起作用。



如果我明确指定URL中的ssh,如 git clone ssh://git@his.server.com:443 / repo.git 它和正常情况一样。

这是否是预期的git行为?为什么第一个url不起作用,但第二个不起作用?

解决方案

是的。 默认克隆语法是类似于scp的。 scp URL看起来像user @ host:path。注意冒号;如果你使用 git@his.server.com:443 / repo.git ,Git认为你想克隆一个路径 443 / repo。 git 来自 git@his.server.com 。如果你需要指定一个端口,你必须使用ssh风格的语法(正如你最终所做的那样)。


A colleague of mine has a remote git repo that I wanted to clone and he provided a url of git@his.server.com:443/repo.git. ssh is listing on port 443 in this case.

I tried to clone by doing git clone git@his.server.com:443/repo.git but the operation times out. I had thought git defaults to ssh as its protocol and I'm not sure why this does not work.

If I explicitly specify ssh in the url like git clone ssh://git@his.server.com:443/repo.git it works just as normal.

Is that expected git behavior? Why does the first url not work but the second one does?

解决方案

Yeah. The "default" clone syntax is scp-like. scp URLs look like "user@host:path". Note the colon; if you use git@his.server.com:443/repo.git, Git thinks you're trying to clone a path 443/repo.git from git@his.server.com. If you need to specify a port, you have to use the ssh-style syntax (as you ended up doing).

这篇关于git克隆需要ssh://协议时,它可能不应该?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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