代码之家  ›  专栏  ›  技术社区  ›  JuanPablo

git远程添加与其他SSH端口

  •  304
  • JuanPablo  · 技术社区  · 14 年前

    在Git中,当我的主机使用不同的SSH端口时,如何添加远程源服务器?

    git remote add origin ssh://user@host/srv/git/example
    
    4 回复  |  直到 8 年前
        1
  •  615
  •   minimalpop    8 年前

    你可以这样做:

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

    1234 正在使用ssh端口吗

        2
  •  141
  •   bramp Madhur Ahuja    14 年前

    Host example.com
        Port 1234
    

    快速的谷歌搜索显示 few different 比我解释得更详细的资源。

        3
  •  35
  •   kujiy    8 年前

    最好的答案对我不起作用。我需要 ssh://

    # 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
    
        4
  •  23
  •   Konrad Rudolph    4 年前

    而不是使用 ssh:// the conventional URL is :

    git@host:path/to/repo.git
    

    要指定备用端口,请在 user@host

    [git@host:port]:path/to/repo.git
    

    但是,如果端口更改只是暂时的,您可以告诉git使用不同的SSH命令,而不是更改存储库的远程URL:

    export GIT_SSH_COMMAND='ssh -p port'
    git clone git@host:path/to/repo.git # for instance
    
        5
  •  18
  •   Evan Carroll    9 年前

    对于你们这些编辑 ./.git/config

    [remote "external"]                                                                                                                                                                                                                                                            
      url = ssh://evanc@www.foo.com:11720/aaa/bbb/ccc                                                                                                                                                                                                               
      fetch = +refs/heads/*:refs/remotes/external/*