在Git中,当我的主机使用不同的SSH端口时,如何添加远程原始服务器?git远程添加其他SSH端口
git remote add origin ssh://[email protected]/srv/git/example
在Git中,当我的主机使用不同的SSH端口时,如何添加远程原始服务器?git远程添加其他SSH端口
git remote add origin ssh://[email protected]/srv/git/example
这不起作用,它默认为22. – jmoz 2012-07-03 16:55:00
它确实为我工作。我喜欢这种方法比把它放在git遥控器上更好。谢谢!无需通过这种方式指定绝对路径。 – 2012-07-21 22:32:23
这很好。同样,我可以有一个特定的键,而不是默认的id_rsa。不仅如此,我的服务器是挑剔的,或多或少你必须迅速地拥有它,如果你包含密码就会失败。所以我也使用'PasswordAuthentication no'。 – 2014-01-08 01:33:28
发现这个链接,虽然它是有帮助我的博客文章可能有助于澄清:
https://prestongarrison.com/change-port-git-is-using-for-ssh/
基本上我认为它更好,只是编辑您的.git/config文件并进行更改。希望这会帮助别人..
您是否可以将相关代码添加到此帖子,而不是让用户点击到外部网站? – iamnotmaynard 2015-12-22 15:43:02
对于那些编辑./.git/config
[remote "external"]
url = ssh://[email protected]:11720/aaa/bbb/ccc
fetch = +refs/heads/*:refs/remotes/external/*
最佳答案对我不起作用。我需要从开始ssh://
。
# does not work
git remote set-url origin [email protected]:10000/aaa/bbbb/ccc.git
# work
git remote set-url origin ssh://[email protected]:10000/aaa/bbbb/ccc.git
Thx。只是一个补充:在路径部分,使用绝对路径,而不是用户主目录的相对路径... – Snicolas 2012-05-28 19:54:21
@Snicolas:为什么不应该使用相对路径? – Hannes 2012-05-30 19:24:40
因为它不起作用。 – Snicolas 2012-05-30 20:10:59