Table of Contents
In laymen terms Git is basically a content tracker. Git shares common principles of most version control systems. However the distinct feature that makes Git unique among the variety of tools is that it is a distributed version control system. This distinction means Git is fast and scalable, has a rich collection of command sets that provides access to both high-level and low-level operations, and is optimized for local operations.
Before we dive into the world of git commands, let’s take a step back and visualize the overview of components that make up the Git ecosystem:
- A Git Server enables you to collaborate more easily because it ensures the availability of a central and reliable source of truth for the repositories you will be working on.
- A Git Server is also where your remote Git repositories are stored; as common practise goes, the repository has the most up to date and stable source of your projects.
- You have the option to install and configure your own Git Server, or forgo the overhead and opt to host your git repositories on a reliable third party hosting site.
- Git clients are of two types: the git command-line and the git GUI tools.
- When you install and configure a git client, you will be able to access the remote repositories, work on a local copy of it, and push changes back to the git server.
- There are many other excellent GUI tools such as GitHub for Desktop, Visual Studio etc
What is Version Control
- Version control (or revision control) is a system that records changes to a file or a group of files and directories over time, so that you can review or go back to specific versions later.
- Quite literally, version control means maintaining versions of your work.
- You may like to think of version control as a tool that takes snapshots of your work across time, creating checkpoints. You can return to those checkpoints any time you want.
- Not only are the changes recorded in these checkpoints, but also information about who made the changes, when they made them, and the reasons behind the changes.
Why we need Version Control
You may have probably visited Wikipedia. Now we all are allowed to modify any of the article on Wikipedia but you must wonder how anyone would know if I just went ahead and deleted some data on any of the Wikipedia post?
This can be tracked via Version Control because any and every edit performed on any Wikipedia article is tracked and you can access this data using "View History" section.
The history page shown in above image lists changes to that page. It also records the time of the change, the user who made it, and a message associated with the change. You can examine the complete details of each edit, and even revert back to an older version of the page. This is a good example of a simple form of version control.
Google Docs, Microsoft 365 etc are some more examples of version control that you might experience in daily life. If you check the revision history of a file in Google Docs you’ll notice that Google saves the state of your file after every few changes.
Different Version Control Types
There are two types of version control systems (VCS), known as “centralized” and “distributed”.
Centralized systems have a copy of the project hosted on a centralized server, to which everyone connects to in order to make changes. Here, the “first come, first served” principle is adopted: if you’re the first to submit a change to a file, your code will be accepted.
In a distributed system, every developer has a copy of the entire project. Developers can make changes to their copy of the project without connecting to any centralized server, and without affecting the copies of other developers. Later, the changes can be synchronized between the various copies.
Overview on Git as Distributed Version Control System
- Git was created by Linus Torvalds (who is also known for the Linux kernel), and Junio Hamano is its primary developer.
- Git, as described on the Git website, is a source code management (SCM) solution, but essentially it’s just a type of version control system.
- Git is a distributed version control system.
- Git tracks your project history, enabling you to access any version of it back in time.
- It also allows multiple people to work on the same project, helping avoid confusion when more than one person tries to edit the same file.
- The primary objective behind Git was to implement and design a version control system that was distributed, reliable and fast.
- While working on Linux, Torvalds needed a version control system to manage the Linux codebase.
- BitKeeper was a distributed system at that time, but Torvalds believed that, although BitKeeper was a good option, being a commercial product made it unsuitable for the development of an open-source project like Linux.
Advantages of Distributed Version Control Systems
- With a distributed system, you can work on your copy of the code without having to worry about ongoing work on the same code by others.
- What makes it even better is that any distributed copy of the project can contain all the history of the project.
- A distributed system also lets you work offline, meaning you can make changes without having access to the server that stores the central repository.
- Another advantage of distributed systems is that you can sync your repositories among yourselves, bypassing the central location. Let’s say the access to the main server goes down and you have to collaborate with a colleague. You can share changes with your colleague and continue to work on the project together, and then later push all your changes to the location everyone has access to.
- In a centralized system, anyone who makes a change needs to be given access to the central location. In contrast, in a distributed system, new developers can make changes to their own repositories without being granted write access, while more experienced contributors can be given write access and the ability to review other contributions before merging them into the repository.
- Managing access is easier in distributed systems.
In this Git tutorial we covered the git basics where we learned about version control, different types of version control, what is git and it's capabilities.