【问题标题】:How to set Mercurial upstream如何在上游设置 Mercurial
【发布时间】:2012-10-08 08:28:57
【问题描述】:

我为新项目创建了本地 hg 存储库:hg init ; hg addremove, 然后我创建了空的上游仓库,并在那里推送了第一个版本:hg push https://remoterepo。

现在,我想将 https://remoterepo 设置为默认上游,这样我就可以在不提供它的情况下执行 hg push/pull。

我很惊讶 Google 没有直接回答“set mercurial upstream”,我也没有在 SO 找到直接答案。那么,为了所有使用 SO 作为操作指南的人的利益,这样做的正确方法是什么?

【问题讨论】:

    标签: mercurial push pull


    【解决方案1】:

    您可以通过将上游 URL 添加到 /project/.hg/hgrc 来做到这一点,如下所示:

    [paths]
    default = ssh://test@bitbucket.com/repos/something
    upstream = ssh://test@bitbucket.com/repos/something_else
    

    现在 upstream 是 repo something_else 的别名,您可以从中提取或推送到:

    hg pull upstream
    hg push upstream
    

    Reference

    hg help urls:

    网址都可以存储在您的 带有路径别名的配置文件 在 [paths] 部分下,如下所示:

      [paths]
      alias1 = URL1
      alias2 = URL2
      ...
    

    然后您可以将别名用于任何 使用 URL 的命令(例如 hg pull alias1 将被视为 hg pull URL1)。

    两个路径别名是特殊的,因为 当你这样做时,它们被用作默认值 不提供命令的 URL:

    1. 默认
    2. 默认推送

    【讨论】:

    • 只添加 default = ... 对我的具体情况起到了作用(使用 hg pull/push 没有任何额外的参数),谢谢。
    猜你喜欢
    • 2010-10-23
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-01
    • 2014-02-07
    • 1970-01-01
    相关资源
    最近更新 更多