Introduction to Version Control and git

What is Version Control?

Version control is a way that you can manage and track any changes you make to your files.

Google docs revision history

Google docs, for example, keeps a revision history of any document you create and modify.

Have a look at this Google document.

  • Select to see the revision history (you must be logged in with your Google account to do that!)

  • And the more detailed version

Scroll through the revisions, from the bottom up. You should be able to see each set of changes highlighted in green.

Wikipedia page history

Wikipedia also holds a history of all changes.

Why do you need Version Control?

  • When used on a regular basis, version control helps you to store your files safely. It makes it easy to figure out what broke your code as you can roll back to a previous version and work out when things last worked as expected.

  • It is also helpful when working with other people as it combines all the changes together, and tracks who, why and when it changed.

Code version control systems

There are a number of different version control systems. The most popular ones are svn (or Subversion), cvs, mercurial and git.

We will be using git.

Why Git?

There are a number of reasons we chose git. To name some

  • A lot of learning resources

  • Does not require you to be connected to the internet to use

  • All your tracked changes stay on your machine until you are happy with them, and want to make them part of your codebase

  • Will tell you if someone has made changes since you last pushed code and urge you to update first and resolve issues

  • Github and online collaboration. Open source code is a big part of today’s life. By being able to retrieve and help existing projects, you can also contribute to them

Some popular project using git:

  • Android

  • Linux

  • Python

  • Ruby

  • PHP

A bit more about Git


  • repository: A repository is where code is stored

  • checkout: When you retrieve code from a repository

  • commit: Applying any changes you have made to the repository

Aim for small and focused changes

When using version control, you should commit every time you do a small piece of work, rather than working for hours in a row, changing too many things and then committing them.

For example, if you want to change the position of an element, the color of all the links on your page and the font size dimensions of all paragraphs, you should do three commits, using messages that describe what you are doing each time.

Bad commit messages

Every time you commit a change use a message that describes your change clearly. In a few months time you will have difficulty remembering why you applied a change if your messages say changing some CSS, another commit, or more changes

Try using messages like repositioned image to look better on page, resolved positioning issue for Firefox.

The next step!

Sign up to Github

Download Github Desktop (for Mac or Windows).

Now what?

Now that you have the Github client setup on your machine, we will spend sometime adding what you have created in the previous lessons on the internet!

  1. Create a new repository

  2. Create a file in the directory you created the repository and write

    This is where I store the work I have done at Codebar

  3. Go to the Github client and commit that file

  4. Now, create a new branch called gh-pages

  5. In the directory, create a subdirectory lesson1 and move the html file you created at the first sessionand all the other relevant files and directories (e.g. /images)

  6. Now, link the file from the root of your project by creating an index.html and adding a link to the page

     <a href='lesson1/index.html'>Lesson 1 - Introduction to HTML </a>

    Don’t forget to rename index to whatever you have named your file!

  7. Commit your changes

  8. Switch to branches on the Github client and hit Publish

  9. View your work on the internet!

    To access your work, go to http://<username>

  10. Repeat the process to list the rest of the tutorials you have worked on on the page as well.


This is your personal page. Use what we learned in the previous lessons to style it, and make it look pretty, and what we learned today to commit and publish your changes.

This ends our Introduction to Version Control and git lesson. Is there something you don’t understand? Try and go through the provided resources with your coach. If you have any feedback, or can think of ways to improve this tutorial send us an email and let us know.