如何使用 Mercurial 进行文本文档的版本控制?

人气:351 发布:2022-10-16 标签: version mercurial document version-control latex

问题描述

这不完全是一个编程问题,但我认为它比 TeX 组

我想使用版本控制来跟踪文本文件的更改(用于创建 LaTeX 输出.(由于我不是程序员,我对版本控制没有更深入的经验系统还没有.)我想为此使用 Mercurial,我正在使用 MacOS X 10.6.

I want to use version control for keeping track of changes of text files (which are used to create LaTeX output. (As I am no programmer, I don't have deeper experience with version control system yet.) I'd like to use Mercurial for that, and I'm working on MacOS X 10.6.

这些文件是关于工作申请的,所以每个公司主要是 3 个文件:

The files are about job applications, so mostly 3 files for each company:

动机信一份简历以及一份包含文凭、证书、...的文件

我有几个关于实际问题的问题:

I have several questions concerning practical things:

我已经有一个包含许多子目录的目录(每个公司一个).每个子目录包含 2 或 3 个 *.tex 文件以及辅助文件和生成的 pdf.(有时还有其他一些包含公司信息的文件).如果我想在新存储库中添加已经存在的文件并从每个文件创建一个修订版(大约有 15 个不同的版本),我该怎么做?当然,父"和子"的关系是不可见的,但至少我可以做一个比较,看看发生了什么变化,每个都有一个修订号.我可以将这些文件保留在原始目录中并将它们添加到版本控制系统中,还是必须将它们放在特殊位置?(我想将其他文件添加到那些目录中,不会添加到版本控制中,我想知道我可以给修订版提供一个名称"(例如公司名称),以便之后更容易找到它们吗?创建新修订的最佳工作流程是什么?我会从存储库中选择一个现有的修订版,将其导出到新公司的新文件夹,更改 tex 文件,然后将其提交回 repo?!

推荐答案

首先,我会推荐两个关于 Mercurial 的免费在线资源:hginit以及Mercurial:权威指南一书.

At first, I would recommend two free online sources about Mercurial: hginit and the book Mercurial: The Definitive Guide.

现在,回答你的问题.

我将从第三个开始.是的,可以为修订附加名称,它们被称为标签.

I'll start with the third. Yes, it is possible to attach names to revisions, they are called tags.

要将现有版本提交到一个存储库中的线性历史记录中,请执行以下操作:

To commit your existing versions into a linear history in one repository do the following:

mkdir myNewRepo
cd myNewRepo
hg init

现在您有了一个新的存储库.对于每个公司目录,重复以下步骤以将文件复制到存储库中,让 hg 知道它们,提交它们并用名称标记新修订.

Now you have a new repository. For every company directory repeat the following steps in order to copy your files into the repository, make them known to hg, commit them and tag that new revision with a name.

cp ../oldVersionA/* .
hg add letter.tex resume.tex diploma.pdf
hg commit -m "Job application to A Inc."
hg tag companyA

请注意,您只需将每个文件路径添加到存储库一次.

Note, that you only have to add every file path once to a repository.

943