Getting started with Git

Posted on

Git is a really powerful piece of version control software. Here is a short crash course on how to get started  on it, I presented at the University of Portsmouth in April 2012.

What is version control?

Version control allows you to keep changes to files organised.

What makes Git so great?

Setting up Git (& SSH Keys)

GitHub have written a really good tutorial on setting up Git on your OS. For the most part, just you need to run through the installer using the default options.

Cloning a Repo

Cloning a repo will copy it’s files & history to your machine. Most git repos will provide you with a URL like The foldername is the directory you wish to clone to.

git clone URL foldername

Reviewing & Staging Changes

Once you have some some edits, you can stage them (Add them into version control with a brief message about what you have done).

# Add all the new files in the repo into the next commit.
git add .

git commit -m 'Message Here'


git commit -a -m 'Message here'


Branches are really powerful, they allow you to work on features independent from other peoples work. So for example, you could have someone adding a new feature to a site while the CSS is being edited in another branch & you will not overwrite each others work. When your happy that the feature is done you can than merge is back into your master brach & deploy it.

Review the branches available

git branch

Change branch

git checkout branchname

Make a new branch

git checkout -b branchname


Git is really good at looking at changes in different versions of a file & merging them together as to not cause errors.

git checkout master; git merge branchname;

Pushing Changes

Pushing a branch updates a remote repo.

git push

Pulling changes

Pulling changes will fetch what others have pushed to a repo & merge them into your local git repo.

git pull


git fetch; git merge origin/branchname

Useful videos