GitHub basics


Git is a system that allows you to keep track of different versions of your code. You can also set up an internet address where others can get hold of the code. A popular implementation of this is the GitHub website (Wikipedia), which provides free space for Open Source projects. GitHub is popular to the point that Git and GitHub are almost synonymous. This tutorial will walk you through using both together, using GitHub's version of the Git software.


Git is a code revision repository system, that is, it sets up somewhere you can store code and which keeps track of different versions of your code so you can roll back changes. It also allows multiple people to work on the code and then merge the changes back onto the repository. Code can also be split into different version 'branches', for example for different teams to work on, or for different software functionalities, and then merged back together.

Git is also a distributed revision control system, meaning that while there may be a central code store (often on GitHub), each user also has their own copy of the code repository (or "repo") which encapsulates their changes. A coder starts by pulling the code from the online version (if there is any). They can then make changes on their local machine. When they want to alter the online copies, they can push their copy of the repository back to the online store. If there are changes from multiple people since a coder last pulled the code down, these changes will be merged, and any conflicts manually managed by either the coder or an administrator.

The final thing to understand is that the local repository is only really like a list of changes. You work on an independent copy of the code, and have to commit changes (update your copy of the repository) when you want to fix that version locally. Once changes are committed you can carry on working and roll back to that version if you want.

So, now we've got the basic idea, let's set up a repository, and try some pushing and pulling.


The first thing you'll need to do is to set up a GitHub account. Go to the GitHub site and set up an account. Obviously only do this if you are happy with their terms and conditions. GitHub is a commercial company, but started by open source enthusiasts. Its model is that people willing to open source their repositories should get free use, and you pay for private repositories. It is probably the most popular, and certainly the fastest growing, repository system with open source developers (other popular sites are Sourceforge; CodePlex; GoogleCode; and BitBucket). If you don't like their terms, you can always utilise the same free software (Git) to set up your own repository system (other popular software includes Mercurial (hg); CVS; and Subversion).


Once you've done this, go to Part 2, where we'll look at using Git to store changes locally.