【问题标题】:Cloning a Mercurial repository without .hg克隆没有 .hg 的 Mercurial 存储库
【发布时间】:2025-07-06 19:15:02
【问题描述】:

如何克隆没有 .hg 文件夹的 Mercurial 存储库以节省时间(项目很大)?我只需要提示文件。

【问题讨论】:

  • 您认为这会节省时间吗?非回购副本会做任何更改吗?

标签: version-control mercurial


【解决方案1】:

.hg 目录用于存储您的完整存储库信息。也就是说,有关您的所有文件及其由存储库跟踪的修订版的信息。至于存储,它通常是非常有效的,因为它是使用二进制差分压缩的。

当您克隆存储库时,唯一被克隆的是 .hg 目录。从.hg 检索克隆后您将获得的工作副本。

如果您只想存储存储库信息(例如在服务器上),您可以使用hg update null 删除工作副本。

如果您想在没有修订信息的情况下创建存储库的克隆,您可以使用hg archive 命令(请参阅下面的参考资料)。请注意,这个副本只是一个“工作副本”(使用一些常见的 svn 术语)。你不能提交,也不能用它做任何其他善变的操作。

hg 存档 [OPTION]... DEST

创建一个未版本化的存档 版本库修订

By default, the revision used is the parent of the working
directory; use "-r" to specify a different revision.

To specify the type of archive to create, use "-t". Valid
types are:

"files" (default): a directory full of files
"tar": tar archive, uncompressed
"tbz2": tar archive, compressed using bzip2
"tgz": tar archive, compressed using gzip
"uzip": zip archive, uncompressed
"zip": zip archive, compressed using deflate

The exact name of the destination archive or directory is given
using a format string; see "hg help export" for details.

Each member added to an archive file has a directory prefix
prepended. Use "-p" to specify a format string for the prefix.
The default is the basename of the archive, with suffixes removed.

选项:

--no-decode  do not pass files through decoders  -p --prefix    

存档中文件的目录前缀 -r --rev 修订以分发 -t --type 要创建的分发类型 -I --include 包括 与给定模式匹配的名称 -X --exclude 排除匹配给定模式的名称

【讨论】:

  • 作为澄清,目的地可能包含格式字符串提供的格式化信息,但普通的旧路径也可以。格式允许您在要归档的路径中对有关 repo 的信息进行编码。