【问题标题】:Mercurial over ssh with config fileMercurial over ssh 配置文件
【发布时间】:2011-08-05 20:52:26
【问题描述】:

假设我有以下 ssh .config 文件:

Host host_nickname
    User xxx
    HostName yyy.zz.vvv
    ControlMaster auto
    ControlPath ~/.ssh/%r@%h:%p

如果您不熟悉 ControlMaster 或 ControlPath,以下是来自ssh_config manual 的描述:

ControlMaster:
         Enables the sharing of multiple sessions over a single network
         connection.  When set to ``yes'', ssh(1) will listen for connec-
         tions on a control socket specified using the ControlPath argu-
         ment.  Additional sessions can connect to this socket using the
         same ControlPath with ControlMaster set to ``no'' (the default).
         These sessions will try to reuse the master instance's network
         connection rather than initiating new ones, but will fall back to
         connecting normally if the control socket does not exist, or is
         not listening.

在 Mercurial 中,如果您想从存储库推送或拉取,您只需键入以下内容:

hg push ssh://user@example.com/hg/

现在,我的问题:

我想请求 Mercurial 推送(或拉取)与我的 ssh 配置条目 host_nickname 对应的服务器上位于 /path/to/repository 的存储库。我该怎么做?

【问题讨论】:

    标签: mercurial ssh


    【解决方案1】:

    如果你查看hg help urls,你会发现

    ssh://[user@]host[:port]/[path][#revision]
    

    所以,假设/path/to/repository 在远程计算机上的登录目录中工作,然后键入

    hg [push|pull] ssh://host_nickname/path/to/repository
    

    这是因为hg 没有进行名称解析; ssh 是,并且你已经指定了host_nickname 和真正的HostName 之间的对应关系。此外,ControlMaster 不会影响这一点,因为它只允许通过单个 ssh 连接进行多路复用。请注意,如果hg 不在您的远程PATH 中,那么您需要通过--remotecmd /path/to/hg 指定它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-02
      • 2010-12-15
      • 1970-01-01
      • 1970-01-01
      • 2013-10-08
      • 1970-01-01
      • 2017-09-20
      相关资源
      最近更新 更多