What Is It?

If you are familiar with cloud storage applications such as Dropbox or Google Drive and how they automatically saves older versions of a file, then you may be more familiar with this concept than you think. Have you ever written an essay or report and had multiple files names like: "FirstDraft", "FirstDraft_Updated", "FirstDraft_Updated_1", "FinalVersion", "FinalVersion_edits" and so on and so on. This tool aims to put an end to all of that.

Put simply, version control is a system that records changes to a file or set of files over time so that you can recall a specific version in time at a later date. For example, if you are writing your theses in LaTeX (which one day you will be) you will inevitably have different versions of it based on which supervisor or postdoc has suggested changes to it, not to mention the changes made or different computers etc. Instead of having dozens of different files you can use version control software to track changes you make, go back to previous versions with ease if you decide you don't like the changes, and create what are called "branches" to write different sections on a tangent to your main branch and then merge those changes once you are happy with them.

So far I hope I have explained well enough what version control is. I won't teach you how to use version control because that is a whole course in and of itself depending on which one you decide to choose. Though I will show you, using the world's most popular version control software Git, what can be achieved and how it can hugely benefit you.


How It Works

As I have said, I will not aim to teach you how to use Git here because that would take forever. However I can point you to some helpful (and free) tutorials and resource that are on the sources page. You should find helpful links for everything discussed in the course and about learning how to use version control software.

The way Git works is by getting snapshots in time of the file(s) you are working on every time you make a commit. A commit is when you tell Git to take one of these snapshots because you have made changes to your file. Git will then look to see what line additions or deletions have been made to your file and will up date them accoringly.

You can also create what are called "branches" in Git which are like copies of your work but on a seperate workflow line. This is usful because it means you can work on experimental features in your code without it affecting your master branch. You can always switch between branches by using a "checkout" command and, when you ar happy with your changes, merge your branches together. This is all illustrated in the adjacent image. Branching is also helpful when multiple people are working on the same bunch of files. It means you can work independently of them without leaking buggy code to the main repository.

It is also possible to tell Git to list a log of all the commits you have made to your code base. It can also tell you about the lines differences, or diffs, that have occured in your current "unstaged" and "uncommited" work. You may have noticed that I've written many words in bold. That is because most of these are commands in Git. It is useful to talk about the processes that a possible in Git by using the commands that execute them.


What It Looks Like

Now you may be thinking "Why talk about Git if you aren't going to show me how to use it?" Which is a fair comment. I've talked about it because I feel it is a very important tool in helping to manage a code base and, if you are using a lot of code in your work, it is an essential tool in keeping track of changes you make throughout your PhD. I have not taught you how to use it because that would be a module all unto itself. Frankly, you can learn git to a basic level and still have it be very useful or you can go as in depth as you like.

Now, without further ado, let me show you what Git looks like and the adjacent image. It is a bash program. In this image the user is initialising their Git repository (i.e. telling Git to start doing tracking changes in the current directory and all subdirectories) and then creating a new branch. If this in anyway looks intimidating to you, do not worry! You don't have to use the terminal or command line. There are third party graphical user interfaces out there that make the whole process a lot prettier! Here is a list of GUIs that run on all platforms varying from free to proprietary. I personally have recommend Git Extensions if you are on Windows as I have used it in the past before. Though feel free to experiemtn with all the different solutions that exists out there!