Using Git for revision control


If you are coding, no matter what it is, games, software, websites, you should be using a code revision control of some sort.
Are you using? Cool. Is it Git? Smart choice, so you probably don’t need to read the rest of this post.

For the rest I’m giving some help on how to start from scratch.

First of all I recommend some reading on Revision Control so that you understand what I’m talking about.

Start by going to Git download page and get the proper one for your system, there’s a Windows, Mac and Linux version.

Next step, to configure it.
Start by opening a Git Bash Console (Windows) or a Terminal (Mac) and do the following:

  git config --global user.name "Your Name"
  git config --global user.email "Your email"

Navigate to your projects folder and do something like:

  mkdir "folder name" //This creates your folder, let's say your game is called Asteroids or something
  cd "folder name"
  git init           // Inits the folder as a Git repository

Now add some file on the folder, a readme.txt or something like that and do this:

  git add readme.txt   // This adds the file to the repository
  git commit -m 'My first commit' // Makes a commit with a message

There you have it, readme.txt is now part of the repository.
Now try changing the contents of the file, save it and commit again with another message.

  git commit -m 'Changed readme.txt'

Git keeps an historic of what was changed =)

For using Git you don’t require to have a dedicated machine for this but for obvious reasons it’s nice to have a web repository that you can access anywhere you go. Let’s say you are working on your desktop, need to go away for a week, you push everything to the server, and keep working on your laptop. Cool right?

I’ve used a couple of online services and lately I’ve switched to github. It’s entirely free if you want to do open-source code or don’t care if others see it. If you need private repositories there are cheap plans available.

I’ll do a more detailed post another time with some of the advanced features.

7 Comments

  1. Do you know if Git handles conflicts better than, say, Subversion? For instance, in our SVN repository (2 users) whenever both of us add files to a XCode project, the second person to commit always end up with a conflict in the project file. Would love a way to solve that 🙂

  2. Hi,
    you might wanna try ProjectLocker instead. The free account offers 300 MB of data and you can have unlimited private repo in one account, as long as it is within the 300mb limit

  3. If you wan’t to keep private repositories for free try http://www.assembla.com/ I’ve been using it for months and even if doesn’t look as neat as Github it provides almost the same tools.

Leave a Reply