SVN Lifecycle
This chapter discusses the lifecycle of a version control system.
Create Repository
A repository is like a centralized space used to store all the work results of developers. The repository can not only store files, but also includes the history of each modification, that is, the change history of each file.
The Create operation is used to create a new repository. In most cases, this operation is only performed once. When you create a new repository, your version control system will ask you to provide some information to identify the repository, such as the creation location and the name of the repository.
Checkout
The Checkout operation is used to create a working copy from the repository. The working copy is the developer's private workspace, where content can be modified and then committed to the repository.
Update
As the name suggests, the update operation is used to update the repository. This operation synchronizes the working copy with the repository. Since the repository is shared by the entire team, when others commit their changes, your working copy becomes outdated.
Let's assume Tom and Jerry are two developers on a project. They both check out the latest version from the repository at the same time and start working. At this point, the working copies are fully synchronized with the repository. Then, Jerry efficiently completes his work and commits the changes to the repository.
At this point, Tom's working copy becomes outdated. The update operation will pull Jerry's latest changes from the repository and update Tom's working copy.
Perform Changes
After checkout, you can perform many operations to make changes. Editing is the most common operation. You can edit existing files, such as adding/deleting files.
You can add files/directories. However, these added files/directories will not immediately become part of the repository; instead, they are added to the change list (pending changes list) and will only become part of the repository after a commit operation is performed.
Similarly, you can delete files/directories. The delete operation immediately removes the file from the working copy, but the actual deletion of the file is only added to the change list (pending changes list) and will only be truly deleted after a commit operation is performed.
The Rename operation can change the name of a file/directory. The "Move" operation is used to move a file/directory from one location to another in the repository.
Review Changes
After you check out a working copy or update your working copy, your working copy is fully synchronized with the repository. However, after you make some modifications to the working copy, your working copy will be newer than the repository. It is a good habit to review your changes before the commit operation.
The Status operation lists the changes made in the working copy. As we mentioned earlier, any changes you make to the working copy become part of the change list (pending changes list). The Status operation is used to view this change list.
The Status operation only provides a list of changes, but does not provide detailed information about the changes. You can use the diff operation to view the detailed information of these changes.
Fix Mistakes
Let's assume you have made many modifications to the working copy, but now you don't want these modifications anymore. At this point, the revert operation will help you.
The Revert operation resets the modifications to the working copy. It can reset one or more files/directories. Of course, it can also reset the entire working copy. In this case, the revert operation will destroy the change list (pending changes list) and restore the working copy to its original state.
Resolve Conflicts
Conflicts may occur during merging. The Merge operation automatically handles things that can be safely merged. Others are treated as conflicts. For example, the "hello.c" file is modified on one branch and deleted on another branch. This situation requires manual handling. The Resolve operation is used to help users identify conflicts and tell the repository how to handle these conflicts.
Commit Changes
The Commit operation is used to transfer changes from the working copy to the repository. This operation modifies the content of the repository, and other developers can view these changes by updating their working copies.
Before committing, you must add the files/directories to the change list (pending changes list). The list records the changes that will be committed. When committing, we usually provide a comment to explain why these changes were made. This comment also becomes part of the repository's history. Commit is an atomic operation, meaning it either fully commits successfully or fails and rolls back. Users will never see a partially successful commit.
Other Extensions