Git is a Version Control System (VCS) and sometimes referred to as Source Code Management (SCM). A software that tracks the changes that have been made to files. Over time when different versions of a file exists, Git will:
- Compare them and display the lines that are different.
- Keep track of all the changes that have been made from one version to the other.
- Merge different versions and changes together.
Git is however not just specific to source code, it can be used for managing versions of this files. For example you are working on a project proposal and you have named the files as proposal_v1.docx, proposal_v2.docx etc. Microsoft Word offers a form of version control through its feature Track Changes. Similarly Adobe Photoshop offer a feature called History. Wikis also offers the same thing.
Source Code Management before Git
Before Git, different other tools have been used to provide version control such as:
- Source Code Control System (SCCS)
- Released in 1972 by AT&T as a closed source product but was free with UNIX. It was used in Universities by students and later found its way in companies. Instead of saving three different versions of the same file it just saved a snapshot of the changes in each version.
- Revision Control System (RCS)
- Released in 1982 as an open source and cross-platform. Instead of keeping the original file as a whole and then keeping snapshots of all the changes made in every version, it did the opposite. Saved the complete file in the latest version and saved snapshot of changes for the older ones.
- Concurrent Versions System (CVS)
- Introduced in 1990, it added features such as able to add version control on multiple files. Additionally now multiple users were able to work concurrently.
- Apache Subversion (SVN)
- CVS was further improved in SVN introduced in 2000. It was faster and allowed saving of non-text files like images also. SVN was not just looking at changes made to certain file but was looking for all the changes happening in a directory. It was the most popular VCS before Git.
- BitKeeper SCM
- Released in 2000 as a proprietary solution but also had a Community Version which was free but had less features. Distributed Version Control was added to it. This free edition was used by the Linux Community for the Linux Kernel from 2002-2005. In April 2005, the Community Version was no more free and so Linux Foundation thought of coming up with their own solution.
Birth of Git
Git was created by Linus Torvalds in April 2005 as an open source product. Like BitKeeper it is also a Distributed Version Control System and is cross-platform. One other advantage is that it is many times faster than other SCMs. It has better safeguards built into it for data corruptions.
How Git Works
In centralized version control systems a copy of the code is placed centrally and users work on their end, when they commit the changes it will placed in the central repository. It is up to the user to keep track of what is happening in the central repository.
In Distributed Version Control Systems however, like Git, different users (or teams of users) maintain their own repositories, instead of working from a central repository. Git is very flexible and different workflows can be implemented with Git.
The changes are stored as “change sets” or “patches”. In other words, Git tracks changes not versions. These “change sets” or “patches” can be exchanged between repositories, merge with other “change sets” or “apply patches”. There are no single master repository instead there are many working copies each with their own combination of change sets.