Day 8 - Version Control System and Git

Day 8 - Version Control System and Git

Before starting with Git, First you have to understand about Version Control System(VCS).

What is Version Control System?

Version Control System is basically a software designed to track changes within one or more files over time.

It allows us to undo or to cancel all made or pending changes within one or more files. If we're working on a project with many files, VCS enables us to control the whole project. If necessary, this allows us to revert one or more files any of their previous versions or the whole project to a previous version. We can also compare changes to one file between two versions in order to see exactly what was changed in each file, when it was changed and who made the changes and why the changes were made.

Types of VCS

The types of VCS are: Local VCS, Centralized VCS and Distributed VCS

  • Local Version Control System(LVCS): A LVCS is a local database located on your local computer, in which every file change is stored as a patch. Every patch set contains only the changes made to the file since its last version. In order to see what the file looked like at any given moment, it is necessary to add up all the relevant patches to the file in order until that given moment.

    The main problem with this is that everything is stored locally. If anything happen to the local database, all the patches would be lost. If anything happen to a single version, all the changes made after that version would be lost.

    Also, collaborating with other developers or a team is very hard or nearly impossible.

  • Centralized Version Control System(CVCS): A CVCS has a single server that contains all the file versions. This enables multiple clients to simultaneously access files on the server, pull them to their local computer or push them onto the server from their local computer. This way, everyone usually knows what everyone else on the project is doing. Administrators have control over who can do what.

    This allows for easy collaboration with other developers or a team.

    The biggest issue with this structure is that everything is stored on the centralized server. If something were to happen to that server, nobody can save their versioned changes, pull files or collaborate at all. Similar to Local Version Control, if the central database became corrupted, and backups haven't been kept, you lose the entire history of the project except whatever single snapshots people happen to have on their local machines.

    The most well-known examples of centralized version control systems are ClearCase and SVN.

  • Distributed Version Control System(DVCS): With DVCS, clients don’t just check out the latest snapshot of the files from the server, they fully mirror the repository, including its full history.
    Thus, everyone collaborating on a project owns a local copy of the whole project, i.e. owns their own local database with their own complete history. With this model, if the server becomes unavailable or dies, any of the client repositories can send a copy of the project's version to any other client or back onto the server when it becomes available. It is enough that one client contains a correct copy which can then easily be further distributed.

    Git is the most well-known example of distributed version control systems**.**

What is Git?

Git, which stands for Global Information Tracker is an open-source version control system used for source code management. It is used to track changes of our source code and maintains a version history.

It also allows us to do Collaboration, that means multiple developers work together on a project, bringing diverse perspectives and expertise.

Hence, all the changes can be tracked and can be reverted to previous one if required.

What is GitHub?

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.

It makes it easy for developers to share code files and collaborate with fellow developers on open-source projects. GitHub also serves as a social networking site where developers can openly network, collaborate, and pitch their work.

Why we use DVCS over CVCS?

  • Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.

  • Greater Flexibility: It allows you to work offline and You have the entire history of the code in your own hard drive, so all the changes you will be making in your own server or to your own repository which doesn’t require an internet connection, but this is not in the case of CVCS.

  • Faster: You don’t need to communicate with the remote server for each and every command. You do everything locally which gives you the benefit to work faster than CVCS.

  • Time Saver: Working on branches is easy in DVCS. Every developer has an entire history of the code in DVCS, so developers can share their changes before merging all the sets of changes to the remote server. In CVCS it’s difficult and time-consuming to work on branches because it requires to communicate with the server directly.

  • Enhanced Security: If the main server goes down or it crashes in DVCS, you can still get the backup or entire history of the code from your local repository or server where the full revision of the code is already saved. This is not in the case of CVCS, there is just a single remote server that has entire code history.

Conclusion

Version Control Systems (VCS) are essential tools in software development that enable collaborative work, track changes, and manage different versions of a project.

Git, one of the most widely used distributed VCS, stands out for its efficiency, flexibility, and speed. It allows developers to work seamlessly in parallel, branching and merging with ease, while providing a robust and decentralized structure for code repositories.

In summary, VCS, particularly Git, plays a crucial role in modern software development, facilitating efficient collaboration and ensuring the integrity and traceability of code changes.

*👆The information presented above is based on my interpretation. Suggestions are always welcome.*😊

~Smriti Sharma✌