如何在 Mercurial 中添加远程存储库?
我通过以下方式使用 Git 存储库:
- 我在不同的生产计算机上拥有主存储库和多个遥控器。
- 我将生产代码推送到远程并重新启动服务以使更改生效。
我即将从 Git 切换到 Mercurial,我想提前知道如何实现类似的目标。
I am working with Git repositories in the following way:
- I have the master repository and several remotes on the different production machines.
- I am pushing the production code to the remotes and restart the services for the changes to take effect.
I am about to switch from Git to Mercurial and I would like to know ahead how I can achieve something like that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您将条目添加到本地克隆的
.hg/hgrc
文件的[paths]
部分。以下是.hg/hgrc
文件中的部分示例:然后,您可以使用
hg Push Remote1
等命令将变更集发送到该存储库。如果您希望远程存储库更新工作目录,则需要在执行更新的远程位置放置一个changegroup
挂钩。这看起来像:并不是每个人都热衷于让远程存储库在推送时自动更新其工作目录,而且它肯定不是默认设置。
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: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 achangegroup
hook in place at that remote location that does an update. That would look something like:Not everyone is a big fan of having remote repos automatically update their working directories on push, and it's certainly not the default.
如果要添加默认路径,则必须在
~project/.hg/hgrc
文件中使用default
。如下:祝你好运。
if you want to add default path, you have to work with
default
in your~project/.hg/hgrc
file. As Follows:Good Luck.
你可以看看 hg-git GitHub 插件:
注意:我尚未使用最新版本的 Mercurial 测试该工具。
You could have a look at hg-git GitHub plugin:
Note: I haven't tested that tool with the latest versions of Mercurial.
如果您使用的是 Unix 并且安装了 Git,则可以使用此 bash 函数轻松添加远程路径,而无需使用文本编辑器:
然后使用以下命令调用它:
如果有人想构建一个 Powershell 等效项,我愿意也包括这一点。其他潜在的改进包括对参数的错误检查以及分解对
$(hg root)
的调用。If you're on Unix and you have Git installed, you can use this bash function to readily add a path to the remotes without a text editor:
Then invoke it with:
If someone would like to build a Powershell equivalent, I'd like to include that as well. Other potentials improvements include error checking on the parameters and factoring out the call to
$(hg root)
.