Different operations in Version Control System


Reading time: 25 minutes

There are different Version Control Systems (like Git and Subversion) and each has its own share of advantages and uses in production systems. It has become a central part of the development process and hence, developing and using VCS like a master is an important topic. Different VCS can look to be different but the basic operations are same.

Following are the different operations in a Version Control System (like Git and Subversion):

  • Create
  • Checkout
  • Commit and Update
  • Add, Edit and Delete
  • Rename and Move
  • Status, Diff and Revert
  • Log and Tag
  • Branch and Merge
  • Resolve and Lock

We will explore each operation in detail now.

1. Create

Create operation here refers to creating a new repository. A repository is a database where all the edits or updates of the source code are stored.

  • Repository keeps track of the tree, i.e., all the files and the layout of the directories in which they are stored.
  • A repository is a three-dimensional entity that exists in a continuum defined by directories, file and time.
  • While creating a new repository, we need to specify the name and the location in which it has to be created.

2. Checkout

The checkout operation is used to make a new working copy for a repository that already exists.

  • A working copy is a snapshot of the repository used as a place to make changes. Though the repository is shared by all the developers, the changes are made only to the working directory first, and then merged with the repository.
  • A working copy is a private space to a developer and changes made to this working copy will not affect the rest of the team.
  • The working copy is actually more than just a snapshot of the contents of the repository, but also contains some metadata so that it can keep careful track of the state of things.

3. Commit and Update

Commit operation is used to apply the modifications in the working copy to the repository as a new changeset.

  • The commit operation takes the pending changeset and uses it to create a new version of the tree in the repository.

The Update operation is used to update the working copy with respect to the repository.

  • The Update is sort of like the mirror image of commit. Both operations are used to move changes between the working copy and the repository.

Commit goes from the working area to the repository. Update goes in the other direction.

4. Add, Edit and Delete

Add operation is used to add a file or directory to the working copy that is not added to version control yet, which has to be added to the repository.

Edit operation is used to modify a file.

  • Edit doesn’t directly involve the VCS, edits are actually made using the text editor or the development environment and the VCS will notice the change and make the modified file part of the pending changeset.

Delete operation is used to delete a file or a directory.

  • The delete operation will delete the working copy, but the actual deletion of the file in the repository is added to the pending changeset.

5. Rename and Move

Rename operation is used to change the name of a file or a directory.

  • The operation is added to the pending changeset, but the item in the working copy typically gets renamed immediately.
  • Rename detection works well in practice, but in case if a file is both renamed and modified, there is a chance the VCS will do the wrong thing.

The Move operation is used to move a file or a directory from one location to the other.

Some of the version control tools treat rename and move as the same operations, while others keep them separate.

6. Status, Diff and Revert

Status operation is used to list the modifications that have been made to the working copy.

  • In other words, status shows what changes would be applied to the repository if it is committed.

Diff shows the details of the modifications that have been made to the working copy (status shows the list alone, but not the details).

A revert is used to undo the modifications that have been made to the working copy.

  • A complete revert of the working copy will throw all your pending changes and return the working copy to the way it was just after the checkout.

7. Log and Tag

The log operation shows the history of changes to the repository.

  • Log operation displays information such as who made the change and when and the log message.

Version control tools provide a way to mark a specific instant in the history of the repository with a meaningful name, called the tag.

8. Branch and Merge

Branch operation is used to create another line of development alongside the current deployment.

  • Branch operation is especially useful when a new version of the software is developed and still the older version has to be kept separate.

Merge operation is used to apply changes from one branch to another.

  • Typically, merge operation is helpful when a branch is used to enable the development to diverge, which later has to converge again, at least partially.
  • Changes can be made in two branches manually, but merge operation makes the process simple by automating this as much as possible.

9. Resolve and Lock

Resolve operation is used to handle conflicts that arise from a merge operation.

  • The resolve operation is used to help the user hoe to figure things out and to inform the VCS about handling of conflicts.

The lock operation is used to get exclusive rights during the modification of file.

  • Not all version control tools include this feature. In some cases, it is provided, but is intended to be rarely used.



Connect with me on LinkedIn and Twitter