如何将Mercurial设置为上游 [英] How to set Mercurial upstream
问题描述
我为新项目hg init ; hg addremove
创建了本地hg存储库,
然后我创建了空的上游仓库,并将第一个版本推送到了hg push https://remoterepo
.
I created local hg repository for new project: hg init ; hg addremove
,
then I created empty upstream repo, and pushed first version there: hg push https://remoterepo
.
现在,我想将https://remoterepo
设置为默认上游,因此我可以不进行设置就进行hg push/pull.
Now, I want to set that https://remoterepo
as default upstream, so I can just do hg push/pull without giving it.
让我感到惊讶的是,谷歌没有给我直接回答设置上游",我在SO上也没有找到直接答案.那么,为了使所有使用SO作为howto方法的人受益,什么是正确的方法?
I was surprised Google did not give me a straight answer with "set mercurial upstream", and I didn't find a direct answer here at SO either. So, for the benefit of all the people using SO as a howto, what's the right way to do this?
推荐答案
您可以通过将上游URL添加到/project/.hg/hgrc
来做到这一点:
You can do that by adding the upstream URL to /project/.hg/hgrc
like this:
[paths]
default = ssh://test@bitbucket.com/repos/something
upstream = ssh://test@bitbucket.com/repos/something_else
现在,upstream
是回购something_else
的别名,您可以从中提取或推入该仓库:
and now upstream
is an alias for repo something_else
which you can then pull from or push to:
hg pull upstream
hg push upstream
URL都可以存储在您的 具有路径别名的配置文件 在[路径]部分下,如下所示:
URLs can all be stored in your configuration file with path aliases under the [paths] section like so:
[paths]
alias1 = URL1
alias2 = URL2
...
然后您可以为任何别名使用别名
使用URL的命令(例如
hg pull alias1
将被视为
hg pull URL1
).
You can then use the alias for any
command that uses a URL (for example
hg pull alias1
will be treated as
hg pull URL1
).
两个路径别名是特殊的,因为 它们在您执行操作时用作默认值 不提供命令的URL:
Two path aliases are special because they are used as defaults when you do not provide the URL to a command:
- 默认
- 默认推送
这篇关于如何将Mercurial设置为上游的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!