Mercurial 通过 ssh 和配置文件

发布于 2024-11-27 23:06:57 字数 1405 浏览 0 评论 0原文

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

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

如果您不熟悉 ControlMasterControlPath,这里是来自 ssh_config 手册

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://[email protected]/hg/

现在,我的问题:

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

Say I have the following ssh .config file:

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

In case you are not familiar with ControlMaster or ControlPath, here is the description from the 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.

In Mercurial, if you want to push or pull from a repository, you could just type the following:

hg push ssh://[email protected]/hg/

Now, my question:

I would like to ask Mercurial to push (or pull) against a repository at /path/to/repository on the server corresponding to my ssh config entry host_nickname. How do I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心荒芜 2024-12-04 23:06:57

如果您在 hg help urls 下查看,您会发现

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

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

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

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

If you look under hg help urls you'll find

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

So, assuming that /path/to/repository works from your login dir on the remote machine, then type

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

This works because hg isn't doing the name resolution; ssh is, and you've specified the correspondence between host_nickname and the real HostName. Also, ControlMaster won't affect this, as that just allows multiplexing over a single ssh connection. Note, if hg isn't in your remote PATH, then you need to specify it via --remotecmd /path/to/hg.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文