Git Guide

Below are some useful commands for using git, GitHub & PyPI from the command line.

Simple Set-up

Git provides local version control - allowing you to keep backups of previous versions of your code.

It's really easy to get started:

That's it, you now have full version control over your code.
It works in Windows, OSX or Linux and is supported by most popular IDEs (including Visual Studio).

You can even take it a step further, by sharing your code on the Web.
GitHub provides a free place to sink & share your code.
It will also allow other people to view & contribute to your code.

You first need to create an account on GitHub, and then a new repo:

new repository

Then copy your repo's address, and add it to your local git account:

Then, once you've committed local changes, you can push them to GitHub:

Setting Up






Branching & Merging

Branching is useful to allow you to develop a new feature, without affecting the main branch.
That way, your main branch remains untouched, until you are ready to add in your new feature.
This is useful, as it means the main branch always matches what is currently released, and it also lets you release emergency fixes on the main branch, without having to include whatever new feature is currently being worked on.

Once your branch is complete, ie. you finished your new feature and are ready to add it to your main branch for a new release.
You simply merge your feature branch back into the main branch.

  1. First you have to checkout the master branch: git checkout master followed by a git pull to get any missing fixes.
  2. Then, there are two options:
    • Merge in your feature branch: git merge <branch>
    • Or pull down your feature branch: git pull origin <branch>
  3. Once you have added your feature branch into the main branch, you then push it all back again: git push
  4. You now have a new version - so you should tag it with a version number