如何在Mercurial中添加远程存储库? [英] How can I add remote repositories in Mercurial?
问题描述
我通过以下方式使用Git存储库:
I am working with Git repositories in the following way:
- 我在不同的生产机器上都有主存储库和几个远程服务器.
- 我正在将生产代码推送到遥控器,并重新启动服务以使更改生效.
我即将从Git切换到Mercurial,我想提前知道如何实现这样的目标.
I am about to switch from Git to Mercurial and I would like to know ahead how I can achieve something like that.
推荐答案
您将条目添加到本地克隆的.hg/hgrc
文件的[paths]
部分.这是.hg/hgrc
文件中的一部分的示例:
You add entries to the [paths]
section of your local clone's .hg/hgrc
file. Here's an example of a section that would go in the .hg/hgrc
file:
[paths]
remote1 = http://path/to/remote1
remote2 = http://path/to/remote2
然后,您可以使用hg push remote1
之类的命令将变更集发送到该存储库.如果您要更新远程仓库的工作目录,则需要在执行更新的远程位置放置一个changegroup
钩子.看起来像这样:
You can then use commands like hg push remote1
to send changesets to that repo. If you want that remote repo to update is working directory you'd need to put a changegroup
hook in place at that remote location that does an update. That would look something like:
[hooks]
changegroup = hg update 2>&1 > /dev/null && path/to/script/restart-server.sh
并不是每个人都喜欢远程存储库在推送时自动更新其工作目录,因此肯定不是默认设置.
Not everyone is a big fan of having remote repos automatically update their working directories on push, and it's certainly not the default.
这篇关于如何在Mercurial中添加远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!