Before we go into what Git is all about, it is essential to explain the basic concepts of version control, branching and merging. These concepts form the foundation on which Git is built. They are essential components of software development and play a crucial role in working with Git:
- Version control
Version control is a system that records changes to a file or set of files over time so that you can revert to specific versions later. Ideally, every file on the computer can be placed under version control, allowing you to revert files to a previous state, revert the whole project to a previous state, review changes over time, see who last changed something that could cause a problem, who introduced a problem and when, and much more. - Branching
Branching is used for version control to maintain stability while making isolated changes to the code. Branching facilitates the development of bug fixes, the addition of new features and the integration of new versions after they have been tested in isolation. - Merging
In version control, merging (also called integration ) is a basic operation to merge multiple changes to a collection of files. This is usually necessary when a file is modified and merged in two independent branches. The result is a single file collection that contains both changes.
What is Git?
Git is the most widely used VCS(Version Control System). Git tracks changes to files so that you have an overview of what has been done and can revert to specific versions if necessary. Git also facilitates collaboration, as changes made by several people can be merged into one source.
Git is software that runs locally. The files and their history are stored on the individual computer. Online hosts (e.g. GitHub) can also be used to store a copy of the files and change history. Having a central place to upload changes and download the changes of others makes it easier for multiple developers to collaborate. Git can automatically merge changes so that even two people working on different parts of the same file can merge those changes later without losing each other's work!
Example:
Your colleague and you are working on a project together, on the same project files. Git now takes the changes that you have made independently of each other and merges them into a single "master" repository. With Git, you can therefore ensure that both of you are working on the latest version of the repository. This avoids a high number of duplicated files.
What makes Git so special:
- Branching and merging is very easy with Git.
- Git enables teams, regardless of their size, to work together with maximum efficiency.
What was it like before Git?
- The developers have transmitted their codes to the central server without having copied their own code.
- All changes made to the source code were not known to the other developers.
- There was no communication between the developers.
With Git?
- Each developer has a complete copy of the code on their local system.
- All changes to the source code can be reproduced by others.
- Regular communication between the developers
Conclusion
Nowadays, modern Software engineering unthinkable without Git. Git is used to track changes to source code, allows multiple developers to collaborate, and supports non-linear development through thousands of parallel branches. It's pretty easy to learn and can save anyone from losing their painstakingly created code.