如何在Mercurial中克隆存储库的子文件夹

如何在Mercurial中克隆存储库的子文件夹

本文介绍了如何在Mercurial中克隆存储库的子文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Mercurial存储库,其中包含一些相关项目.我只想将这些项目之一分支到其他地方.

I have a Mercurial repository containing a handful of related projects. I want to branch just one of these projects to work on it elsewhere.

克隆仅仅是一部分存储库,这是实现这一目标的正确方法吗?

Is cloning just part of a repository possible, and is that the right way to achieve this?

推荐答案

您想要的是 部分克隆,但是很遗憾,尚不支持此克隆.

What you want is a narrow or partial clone, but this is unfortunately not yet supported.

如果您已经有一个大型存储库,并且意识到将其拆分为几个较小的存储库是有意义的,则可以使用转换扩展名以进行从水银到水银的转换.请注意,这会创建一个 new 存储库foo,并且您不能在your-big-repofoo之间推/拉.

If you already have a big repository and you realize that it would make sense to split it into several smaller repositories, then you can use the convert extension to do a Mercurial to Mercurial conversion. Note that this creates a new repository foo and you cannot push/pull between your-big-repo and foo.

默认情况下未启用convert extension,因此请将以下内容添加到存储库的hgrc文件或mercurial.ini文件中:

The convert extension is not enabled by default so add the following to your repo's hgrc file or your mercurial.ini file:

[extensions]
hgext.convert=

然后使用

include "libs/foo"
rename "libs/foo" .

(请注意,即使在Windows上也可以使用正斜杠)并运行

(note you can use forward slashes even on Windows) and run

$ hg convert --filemap map.txt your-big-repo foo

这将使foo成为具有your-big-repolibs/foo文件夹的完整历史记录的存储库.

That will make foo a repository with the full history of the libs/foo folder from your-big-repo.

如果要从your-big-repo中删除所有foo证据,则可以进行另一次转换,在其中使用exclude libs/foo摆脱目录.

If you want to delete all evidence of foo from your-big-repo you can make another conversion where you use exclude libs/foo to get rid of the directory.

当您拥有多个这样的存储库并且想要整体使用它们时,则应查看子存储库.此功能使您可以在结帐中包括其他存储库,这与svn:externals的工作方式类似.请遵循该Wiki页面上的建议.

When you have several repositories like that and you want to use them as a whole, then you should look at subrepositories. This feature lets you include other repositories in a checkout — similarly to how svn:externals work. Please follow the recommendations on that wiki page.

这篇关于如何在Mercurial中克隆存储库的子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 23:41