I remember starting my DevOps career by getting familiar with 2 ‘painful’-to-learn tools. The first was XML, in which I was required to be certified, and the second was Git. I was offered a 300+ book to study the fundamentals, which I gave up reading in chapter 1. I am not a git expert by any stretch of the imagination, however, when actively coding, it is a technology I interact with several times a day. I was new to the lifetime learning marathon of new technologies that come with the job and thought I could get my way through it by watching videos, and not practicing – rookie mistake. I ended up watching a professor give a 2-hour lecture on the algorithms Torvald (Linux inventor) coded into Git, which did not help at all. By the end of it, I had no idea why this was so special. So let’s start there.
This week’s blog is definitely more widespread than usual as it concerns Version Control. This particular tool is something that you’d be hard-pressed (or at least you should be!) to find not being utilized by any modern company. In this blog, we will explore what it is, why it’s important, and how you can get started.
The Problem
Imagine you are working on a set of presentations for a weekend conference. Your team is giving 7 in total. You’re all working on the slide decks, it all looks to be going well as the slides are all saved on the company server. Saturday morning, day 1 of the conference, one of your colleagues comes to you all tired after pulling an all-nighter to get the slides updated. The rest of your team is confused – wasn’t it all done? He goes on to say that he got the memo that the slides needed to be updated with the new data, images, and links. Your eyes widen as you realize what happened – your colleague misread the email! He made the changes using the data meant for the December conference! You scramble to a computer, but alas, there are 7 slides and no backups…” Hello darkness my old friend…”
It’s all there
This, of course, a little bit exaggerated, is what version control is all about. Version control is like an ultra version of the ‘undo’ or ‘history’ button. It’s a system that saves multiple versions and states of files in a directory along with all the ways in which the directory and the files within it are manipulated. It lets you see exactly who changed what, when the change was made and what the state of the files was back to when the first line of each file was written. Git allows you to retrieve any state that a file has ever been in – which, if used well, means you can always ‘rewind’ your files to a state when everything was working wonderfully.
Collaboration
One of the other primary reasons Git works so well is its incredible collaborating features. You can have a team of 50 developers, all working on the same source code. This code can have multiple versions at different stages of development as different teams all work on various features at the same. Git allows each developer, or team, to work on a copied version of the code, called a feature branch, and maintain a single version of the truth, called the master branch. When pieces of code are completed by different teams on their respective branches, they can all be merged back into the master branch – the final source of truth and the code that is actually used in production. Git allows all these versions (branches) to be tracked, developers to switch from branch to branch, and all developers to merge their code to the master in an ordered fashion when it’s ready. This was everyone can work on the same code, without ever accidentally breaking the Master branch’s code during development.
Security
Git uses hashing algorithms to ensure that the changes made to the code, the code itself, and its history cannot be tampered with. This means that teams working with Git can be sure they are viewing the true version of the code with transparency to view its entire journey.
Git on it
If you are an aspirant towards working with any kind of software development professionally, you must understand the workings of git, that’s why our sponsor (Insert link to sponsor’s product here :P)
Joking aside, I started practicing git with https://learngitbranching.js.org/ which runs fully within the browser. This site lets you practice git with some simulated examples. Version control with Git is one of those things you need to see and practice with to understand why it works. To be honest – it was only until I messed up a project’s source code that I learned the gold that Git truly is.
So I hope you can explore, learn, and maybe start your own GitHub or Bitbucket account where you can make sure you never lose all the important code you are working on as you Git ‘n the cloud!