Version Control Basics — 1. What the heck is it?
What is a Version Control System?
It is software that automatically tracks file content changes over time. It can tell you what/where/when/how something was changed, and by whom. Version control is also sometimes called Source Control.
Let’s jump into an alternate universe, where there is no version control software.
- You have a working web application and you added a new feature. But your change broke the application layout. And you have no idea, why! Because everything seems perfect to you. Now, the next thing you do, you try to fix this and undo your steps manually. You revert your changes file by file, trying to bring it back to the old state, but that doesn’t help. Now imagine, if you had a tool that maintained save-points for your application. You could roll back and go back in time, to get your old application state immediately.
- Suppose your team manages a word document that is regularly updated. Now, if some data was deleted 2 days back, and you need to refer to the same, you don’t have it now. Now, what if you had a tool, that manages this document and allows you to peek into the changes, that were made during that timeframe? What if you could even make the document go back to the same state it was 2 days back?
- Developers constantly modify files. For remote developers around the globe, could even be working on the same files, or even, make changes to the same lines in code. Once completed, they would update their changes to the central copy. At this point, there are high chances of conflicts in the code base, when other developers try to update the same central copy. If there is no version control, it would be really difficult to know what changes are required and what are not.
With continuous changes sent in by your team, when any of these above situations happen, you have no option but to feel sad about your life. You end up cursing in a corner, as you don’t know what to do next.
You may argue there is an easy answer to this.
“Do it yourself”.
So you start with maintaining initial backup copies of the files before you start working on them. Now, if anything goes wrong, you still have the old copy. Well, that’s partially correct. What you are really doing, is manual version control. Typical example formats would be, maintaining the same filenames with different names denoting their versions or associating them with timestamps, like
- appDesign_v1.docx, app_Design_v2.docx, app_Design_v3.docx
- appDesign_20210405.docx, appDesign_20210410.docx, appDesign_20210410.docx
- layout_v1.html, layout_v2.html, layout_v3.html
- userProfile_1.java, userProfile_2.java
And I hope you can understand the reasons to avoid this -
- This is poor resource management, as the same files are not efficiently stored but duplicated.
- They are highly prone to human errors.
- It really gets confusing when there are multiple files with different manual versions.
- Not only manual maintenance is a headache, but this is stupid.
And that’s where Version Control Systems fit in.
A VCS records changes. Each unit of change is measured as a commit. For a certain changeset (commit), it maintains point-in-time snapshots of the files. As the development codebase gets more and more complex, there is a bigger need to maintain the source code using version control systems.
So what are all the benefits it brings along?
- It maintains a complete history of every change for every file.
- It allows us to focus only on the relevant change we introduce. This helps to reduce the possibility of errors.
- We could travel back and forth between changes in a project, to understand when was a change was introduced.
- It efficiently manages changes in a project, along with some essential information, like who introduced a change, at what point in time, and what the change was all about.
- Anybody can contribute from any geographical location. It has a concept of branching, where it allows different team members to work concurrently.
- It improves productivity and allows better collaboration by making the development process really smooth.
- It helps in code recovery if your copy gets corrupted due to some reason.
Version control is really an important and useful tool to track changes. Developers who have good knowledge about VCS can easily work with huge codebases and their productivity increases exponentially. Now, at this point, there are several version control systems in the market: Git, SVN, Mercurial, OpenCVS. So, if you look at the choices, there are many to pick from.
I would recommend Git as it is free, open-source, and highly popular. It is really easy to learn and you can get started in minutes.
If you would like to learn about the different types of Version Control Systems, check out the below article.
Thank you for reading. Keep learning and growing. Cheers! :-)