Development tools: Version Control
If you’re a developer you should already know about version control, however if you have never heard of it you may be wondering what it is all about or more importantly why is there an article on GeekOut about it. As a developer, it’s a critical tool for what I do and if you’re looking to get into development then you’re going to need to learn it. The fact is you may already use software that has version control integrated into it. Google Docs, Sheets and even Presentations have a built in version control system which enables you to not only see changes that you have made throughout the history of the document but also changes that other people have made that you have shared the document with.
Software Developers have been using version control for decades, it’s an essential tool for development purposes and has changed so much especially since the release of Git and Mercurial in 2005. So I could just let you go and read the Wikipedia pages for Version Control but that would make this article very short. I think it would be more interesting if I told you a story about why I think Git has made such a massive impact on the development community.
When I first started to work as a software developer I had never heard of versioning, I kept manual backups of files I was changing. This works fine when you’re a sole developer but as soon as I started working in a team I began to use the versioning software known as CVS. With this, I could begin to merge together the changes that me and any other developer I was working with. It was still not always easy, every developer I encountered that was using the same package would hate to have to support multiple branches. If you’re confused, bear with me and I will try to explain.
Take a look at the diagram on the left which I liberated from Wikipedia. You can think of the development process a bit like a tree, the main product that you’re working on is sometimes called the trunk or in Git terms ‘master‘. Just like a tree a sub-section of work is called a branch. This branch goes ahead and changes the code as much as it needs to with the aim to be eventually break off the branch and merge it into the trunk. You can create a branch from anywhere which comes in very useful when you are working on a big change or if you are planning a major new release. Where tools like Git come in really useful is when you want to merge the code that is sitting on your branch back into your trunk. You see while you have been happy making new things maybe other developers have corrected things that are currently not working properly or added some new small bits of functionality and your changes now have to fit with theirs.
Before tools like Git and Mercurial existed I used two others called Subversion (SVN) and CVS (Concurrent Versions System), now to do what I do today in Git in either of these two bits of software was a complete nightmare. Making a branch was tricky and merging it even more so. When Linus Torvalds redesigned the way code versioning worked I remember him distinctly talking about how it should be a lot easier to branch and then merge. This change alone I believe has given a great deal more flexibility on how development works today.
You may actually be asking “When does versioning really matter?” Well, the answer to that is always. It can save you a great deal of time and when your working in the industry time can directly correlate to money. If you’re working with multiple developers it can save you a great deal of time by merging two changes to the same file even if you have both edited the same line. Git also comes in really useful when you want to undo changes or checkout the code from some time ago to see if the problem has been introduced in a certain version. You can do this with individual files as well as the whole codebase. So yes versioning can be very useful and I aim to use it to continue our development tutorial so if you’re going to follow along with that we advise you install it. If you’re on a Linux based system it probably much easier for you to install it using whatever package manager you work with.
For Ubuntu/Debian Linux based systems you would run
sudo apt-get install git
For Centos Linux based systems you would run
sudo yum install git
On a Mac life is just as simple, you can download and install from the Git website or just install Apples Xcode system which has a copy of Git in it. If you run an older Mac then you could try installing it via Brew. For Windows, you can download and install direct from the Git website. If you’re interested to read more about Git and how to use it then there are several good documentation pages and there is an entire online book about it. Don’t worry you won’t have to read all of these we will delve more into Git as we go.
If you have any questions about Git or Version Control then please feel free to ask them, I shall try as best as I can to answer them. You can ask them in the comments section or over on Reddit, FaceBook or Twitter
Love and rockets