Svn 简明教程

SVN - Life Cycle

本章讨论了版本控制系统的生命周期。在之后的章节中,我们将了解每项操作的 Subversion 命令。

The life cycle of a Version Control System is discussed in this chapter. In later chapters, we will see the Subversion command for each operation.

Create Repository:

存储库是开发人员存储所有其工作的中心区域。存储库不仅存储文件,还存储有关更改的历史记录。这意味着它维护了对文件所做更改的历史记录。

The repository is a central place where developers store all their work. Repository not only stores files, but also the history about changes. Which means it maintains a history of the changes made in the files.

“创建”操作用于创建新的存储库。大多数情况下,该操作只执行一次。在您创建新的存储库时,您的 VCS 将期望您说出某些内容来识别它,例如您希望将它创建在哪里,或应该为该存储库命名什么。

The 'create' operation is used to create a new repository. Most of the times this operation is done only once. When you create a new repository, your VCS will expect you to say something to identify it, such as where you want it to be created, or what name should be given to the repository.

Checkout

“签出”操作用于从存储库创建工作副本。工作副本是开发人员进行更改的私人工作空间,稍后将这些更改提交到存储库中。

'Checkout' operation is used to create a working copy from the repository. Working copy is a private workplace where developers do their changes, and later on, submit these changes to the repository.

Update

顾名思义,“更新”操作用于更新工作副本。该操作使工作副本与存储库同步。由于存储库由所有团队共享,其他开发人员可以提交其更改,而您的工作副本变得旧了。

As the name suggests, 'update' operation is used to update working copy. This operation synchronizes the working copy with the repository. As repository is shared by all the teams other developers can commit their changes and your working copy becomes older.

让我们假设 Tom 和 Jerry 是正在进行一个项目的两位开发人员。两人从存储库检出最新版本并开始工作。此时,他们的工作副本与存储库完全同步。Jerry 非常有效率地完成了他的工作并将他的更改提交到了存储库。

Let us suppose Tom and Jerry are the two developers working on a project. Both check out the latest version from the repository and start working. At this point, their working copies are completely synchronized with the repository. Jerry completes his work very efficiently and commits his changes to the repository.

现在,Tom 的工作副本已过时。更新操作将从存储库拉取 Jerry 的最新更改,并将更新 Tom 的工作副本。

Now Tom’s working copy is out of date. Update operation will pull Jerry’s latest changes from the repository and will update Tom’s working copy.

Perform Changes

在签出后,可以执行各种操作来执行更改。编辑是最常见的操作。可以编辑现有文件以添加/删除文件中的内容。

After the checkout, one can do various operations to perform changes. Edit is the most common operation. One can edit the existing file to add/remove contents from the file.

可以添加文件/目录。但是,这些文件/目录不会立即成为存储库的一部分,而是会被添加至待定更改列表,并在提交操作后成为存储库的一部分。

One can add files/directories. But immediately these files/directories do not become a part of the repository, instead they are added to the pending change-list and become a part of the repository after the commit operation.

同样,可以删除文件/目录。删除操作会立即从工作副本中删除文件,但文件的实际删除将被添加到待定更改列表,并在提交操作后对存储库进行更改。

Similarly one can delete files/directories. Delete operation immediately deletes file from the working copy, but actual deletion of the file is added to the pending change-list and changes are made to the repository after the commit operation.

“重命名”操作会更改文件/目录的名称。“移动”操作用于在存储库树中将文件/目录从一个位置移动到另一个位置。

'Rename' operation changes the name of the file/directory. 'Move' operation is used to move files/directories from one place to another in a repository tree.

Review Changes

在签出工作副本或更新工作副本时,工作副本将与存储库完全同步。但是,在对工作副本进行更改时,它将比存储库更新。在“提交”操作之前,最好检查你的更改。

When you check out the working copy or update the working copy, then your working copy is completely synchronized with the repository. But as you do changes to your working copy, it becomes newer than the repository. And it is a good practice to review your changes before the 'commit' operation.

“状态”操作会列出已对工作副本进行的修改。“状态”操作用于查看待定更改列表。

'Status' operation lists the modifications that have been made to the working copy. As we have mentioned before, whenever you do changes in the working copy all these changes become a part of the pending change-list. And the 'status' operation is used to see the pending change-list.

“状态”操作仅提供更改列表,但不提供详细信息。可以使用 diff 操作查看对工作副本所做的修改的详细信息。

'Status' operation only provides a list of changes but not the details about them. One can use diff operation to view the details of the modifications that have been made to the working copy.

Fix Mistakes

让我们假设你已对工作副本进行了更改,但现在,你想放弃这些更改。在这种情况下,“还原”操作将有所帮助。

Let us suppose one has made changes to his working copy, but now, he wants to throw away these changes. In this situation, 'revert' operation will help.

还原操作会还原对工作副本所做的修改。可以还原一个或多个文件/目录。也可以还原整个工作副本。在这种情况下,“还原”操作将销毁待定更改列表,并将工作副本恢复到其原始状态。

Revert operation reverts the modifications that have been made to the working copy. It is possible to revert one or more files/directories. Also it is possible to revert the whole working copy. In this case, the 'revert' operation will destroy the pending change-list and will bring the working copy back to its original state.

Resolve Conflicts:

冲突可能发生在合并时。“合并”操作会自动处理所有可以安全完成的操作。其他所有内容都被视为冲突。例如,“hello.c”文件在一个分支中被修改,而在另一个分支中删除。这种情况下,需要一个人做出决定。“解决”操作用于帮助用户理清思路,并通知 VCS 关于处理冲突的方法。

Conflicts can occur at the time of merging. 'Merge' operation automatically handles everything that can be done safely. Everything else is considered as conflict. For example, "hello.c" file was modified in branch and deleted in another branch. Such a situation requires a person to make the decision. The 'resolve' operation is used to help the user figure out things and to inform VCS about the ways of handling the conflicts.

Commit Changes

“提交”操作用于将工作副本中的更改应用到存储库。此操作会修改存储库,其他开发人员可以通过更新其工作副本来查看这些更改。

'Commit' operation is used to apply changes from the working copy to the repository. This operation modifies the repository and other developers can see these changes by updating their working copy.

在提交之前,必须将文件/目录添加到待定更改列表。这是更改等待提交的地方。在提交时,我们通常会提供一条日志消息以解释某人为何进行更改。此日志消息成为存储库历史的一部分。提交是一个原子操作,这意味着整个提交要么成功,要么回滚。用户永远不会看到半成品提交。

Before commit, one has to add files/directories to the pending change-list. This is the place where changes wait to be committed. With commit, we usually provide a log message to explain why someone made changes. This log message becomes a part of the history of the repository. Commit is an atomic operation, which means either the entire commit succeeds or it is rolled back. Users never see half-finished commit.