Mercurial 通过 ssh 和配置文件
假设我有以下 ssh .config 文件:
Host host_nickname
User xxx
HostName yyy.zz.vvv
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
如果您不熟悉 ControlMaster 或 ControlPath,这里是来自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在
hg help urls
下查看,您会发现So,假设
/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 findSo, assuming that
/path/to/repository
works from your login dir on the remote machine, then typeThis works because
hg
isn't doing the name resolution;ssh
is, and you've specified the correspondence betweenhost_nickname
and the realHostName
. Also,ControlMaster
won't affect this, as that just allows multiplexing over a single ssh connection. Note, ifhg
isn't in your remotePATH
, then you need to specify it via--remotecmd /path/to/hg
.