git remote add with other SSH port

2019-01-07 01:36发布

In Git, how can I add a remote origin server when my host uses a different SSH port?

git remote add origin ssh://user@host/srv/git/example

标签: git ssh port
4条回答
男人必须洒脱
2楼-- · 2019-01-07 02:12

Best answer doesn't work for me. I needed ssh:// from the beggining.

# does not work
git remote set-url origin user@example.com:10000/aaa/bbbb/ccc.git
# work
git remote set-url origin ssh://user@example.com:10000/aaa/bbbb/ccc.git
查看更多
淡お忘
3楼-- · 2019-01-07 02:13

You can just do this:

git remote add origin ssh://user@host:1234/srv/git/example

1234 is the ssh port being used

查看更多
▲ chillily
4楼-- · 2019-01-07 02:26

You need to edit your ~/.ssh/config file. Add something like the following:

Host example.com
    Port 1234

A quick google search shows a few different resources that explain it in more detail than me.

查看更多
倾城 Initia
5楼-- · 2019-01-07 02:33

For those of you editing the ./.git/config

[remote "external"]                                                                                                                                                                                                                                                            
  url = ssh://evanc@www.foo.com:11720/aaa/bbb/ccc                                                                                                                                                                                                               
  fetch = +refs/heads/*:refs/remotes/external/* 
查看更多
登录 后发表回答