Before we start learning Java, we need to understand how to save our code and collaborate with other developers, just as we would when working in a team. This is important because, in a company, developers divide tasks and work on them simultaneously to complete projects efficiently. We also need a way to restore code to previous versions in case an error occurs in the current version. This is where a version control system (VCS) comes in.
What is a Version Control System?
A version control system is software that helps developers track the three Wโs while handling code:
- Who made the change
- When the change was made
- Where the change was made
These three questions can help us understand why an error might have occurred.
The VCS takes a snapshot of every modification, allowing you to revert to a previous version if you make a mistake. ๐
History of Version Control Systems
Initially, files were stored in multiple local directories, which was prone to errors. To address this, the local version control system was introduced, where all versions were stored in a local repository. One of the oldest systems, RCS (Revision Control System), was introduced in 1982.
However, this method was not feasible for teams, leading to the introduction of the centralized version control system (CVCS). These systems used a central server to store all versions. The main drawback was that CVCS had a single point of failureโif the central server was corrupted or lost, the data could not be recovered. Additionally, large teams found it difficult to work efficiently with this system.
To overcome these drawbacks, the distributed version control system (DVCS) was introduced. In this system, every workspace/system has its own local repository and working copy, along with a central repository for synchronization.
Terminology in VCS
Working Directory โ The folder where the code is stored.
Repository โ Maintains different versions of the code.
Commit โ Saves changes to the repository.
Checkout โ Retrieves code from the repository to the working directory.
Types of Version Control Systems
Centralized Version Control System (CVCS) โ Uses a central server to store all versions.
Distributed Version Control System (DVCS) โ Every system has a local repository, along with a central server.
Top comments (0)