Understanding Git(Part 1)- Concept of Version control
Hey, Welcome All for the series on Git.
Before we dive into git, let’s see what version control is on which the entire concept of Git is built.
Version Control (also known as source control) is a system that keeps track of changes that we make to our file or set of files.
It also records the details like who made the changes and why they made them. This lets us backpropagate to the histories of changes.
We can use version control for configuration files, documentation, data files, or any other content.
So why we need Version control?
Consider that you are working on an excel sheet, so when you want to make a change, we make a copy of the file with a timestamp and work on it.
When there is a situation where you want the older version, we can roll back to the particular bug-free versions without any problem.
Version-controlled systems enable multiple developers or teams to work in an isolated fashion without impacting others' work. This isolation enables features to be built, tested, integrated, or even scrapped in a controllable, transparent, and maintainable manner.
How we achieved this before version control?
Consider that you are working on a document where you have multiple sections to work on. Let’s assume you have completed 3 sections of the document, but some typos are in those sections. Now you want your colleague's help to fix the typos while focusing on completing the documents. So you sent your documents to a colleague and asked him to fix the typos.
Your colleague fixed the typos, and he has shared the changes with you.
If he shares the corrected file with you, you have to run a diff command on the files.
diff document.txt document_fixed.txt
The diff command will display the variation between the files. Using this, you can find where your colleague have corrected the mistakes.
We can see that diff showing us the change in the master file with the corrected file.
But what if you have included more sections in the document? Finding the typo changes suggested by your colleague in your document will be more difficult.
To solve this difficulty, you can ask your colleague to send a diff file.
The Diff file contains the variation among the two files.
diff document.txt document_fixed.txt > document.diff
Now he has shared a diff file, let’s see how to apply those changes to our files.
patch document.txt < document.diff
Using the patch, we can apply the changes directly to our document without going line by line of each section of the document.
When a patch is successful, you will be prompted with a message patching file document.txt.
If we look into our original document, we can see the changes suggested by your colleague are applied.
How were we achieving these now?
To achieve this, we will look into Git, the worlds leading version control distributed system.
One of the essential skills in your developer toolkit is knowing how to work with version control systems.
From working on personal projects to building professional-grade software, it’s part of today’s software development workflow and a critical component in protecting and managing your source code.
In the upcoming series, we can dive much deeper into how we can use git.