Step 1 to becoming a software engineer, let’s introduce version control (Part 1)

Patrick Farrell
codeburst
Published in
5 min readDec 15, 2017

--

In a recent blog post, I talked about the difference between learning to code and becoming a software engineer. Since I don’t just want to teach you to code, we are going to start with my most important tool for becoming a software engineer, version control.

So what is Version Control?

I’ve written a blog post in the past about this topic, but I’m going to start at the beginning here. Version control is a way of keeping track of all your changes to a document or folder. It basically allows you create points in history for any change that you have made to a file, and go back to that identical version of the file at any point in the future.

One of the most common version control tools out there is git. I use git every day and its one of those tools that once you learn it, it will save you tons of time and you will wonder how you lived without it.

Git Concepts

So what are the basic concepts behind git? At the core, there are only a few of them. The first one is called a commit; a commit is just a point in history that I decide when I want to create.

Let’s say I create a file that has one line “Hello Brooklyn” and I want to create a point in history for that file so I can view it or reference back to it in the future. I would create a commit for it; lets call this commit 1.

Your first commit — your first piece of history of this project

Then let’s say I want to edit that line to now read “Hello Brooklyn, I’m glad to be back.” I now want to create commit 2 that represents the second point in history.

Figure 2

So now we have two points in history for this file we have just created, commit 1 and commit 2. Now what do we do with them?

Well now we need to learn our second git term which is checkout. By default, you are already checked out at the last point in history that you just made, so our file currently says “Hello Brooklyn, I’m glad to be back.”

But what if we wanted to go back to the first version of the file, the one where the file just said “Hello Brooklyn,” well all we have to do is checkout commit 1 which tells us which point in history we are looking at, and then refresh the file.

If I then decide I want to go back to the newer version of the file, I can just checkout commit 2 again.

So now let’s talk about our third git term which is branch. Since we know that commits are points in history, a branch what tells us which point in history we are pointing to.

By default, you have a branch called master which we were using to create the first two commits from earlier, 1 and 2. You can see it in Figure 2 above. How do we actually go back and checkout commit 1 if we are pointing to commit 2?

Well there are actually multiple ways to do this with git, but the easiest to describe right now is to just create a new branch. Branches are what we call pointers, they point to different points in history.

Let’s call this new branch “older”. As you can see in Figure 4 below, we now have two branches, which are represented by these green boxes. But we are still checked out on the master branch which is the branch with the bold text.

Figure 3

So now we actually want to checkout the “older” branch so we can see the version of the file that just says “Hello Brooklyn”, we do this with a command that I will introduce in a future post but for now you can see in Figure 4 that older is now in bold.

Figure 4

This means that we are now checked out on the older branch and pointing to commit 1 which is our first point in history in this project, and as you can see the file now says “Hello Brooklyn” again.

I’m going to end this blog post here and continue on in part 2. Please comment below and tell me what was confusing about this post or ask any questions you may have. I would like to turn this into a valuable resource for everyone, thanks for reading.

--

--

Founder and Business Coach for Online Entrepreneurs and Coaches. I help people create more freedom in their life and connect to their purpose.