为什么补丁可以随时重新创建任何文件?

Why the patches can re-create any file at any point?

我无法理解:补丁集可以重新创建任何文件在任何时间点的样子。

git-scm.com

One of the most popular VCS tools was a system called RCS, which is still distributed with many computers today. RCS works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.

一个简单的例子来清除它:

历史:

1) 我创建文件 myfile.txt

2) 我粘贴在"This is some sentence."

3) 我把"is"这个词删掉了。

4) 我添加一行 "This file is a mess."

不难看出 myfile.txt 在第 3 步之后处于什么状态,尽管从未明确给出。您所拥有的只是初始状态和更改历史记录。不像 git,那里有连续的快照。

在 git 中,提交看起来像(为了简单起见,描述非常松散)

1) myfile.txt
""

2) myfile.txt
"This is some sentence."

3) myfile.txt
"This some sentence."

4) myfile.txt
"这句话。
这个文件很乱。"


在第一个范例 (RCS) 中,您已经有了变更集,但必须重新创建快照。在另一个 (git) 中,您已经有了快照,但必须重新创建变更集。