Skip to content
Andy Balaam edited this page Mar 1, 2016 · 8 revisions

Introduction

Git is the system we use to store the code, graphics etc. for Rabbit Escape. It can be very intimidating to use at first, but do ask for help (by creating a GitHub issue) if you are having trouble.

For a general introduction to Git you may find the video series Git by Andy Balaam helpful, and for the topics covered on this page, the last video Using GitHub and GitLab is most relevant (although it does assume you have watched the previous videos first).

Your first contribution

To contribute something (code, graphics, animations, music, levels, ...) it is helpful if you can use a GitHub pull request. You are asking for your work to be pulled into the project. In Git all repositories are equally capable entities, but we do assign purposes to them.

  • Create a GitHub account. (Mine is colonelfazackerley, as you will see in the examples).
  • Go to the rabbit escape pages and click "fork". This makes a copy of the repository under your account. Soon (wait for it) you will have a working copy of the repository on your own computer. As far as your working repository is concerned your GitHub fork is called "origin".
  • Go to your rabbit escape fork on GitHub. Mine is https://github.com/colonelfazackerley/rabbit-escape. Find the clone URL and copy it. Then clone. This makes a directory called rabbit-escape and puts all the source in it I will call this a working copy. For me this is
git clone https://github.com/colonelfazackerley/rabbit-escape.git

You need to tell git who you are before you can commit (something you will do soon). For me this is.

git config --global user.email [email protected]
git config --global user.name  colonelfazackerley
  • Now you are ready to make the changes to demonstrate your great new idea. Create a branch called "genius". From a directory under rabbit-escape.
git checkout -b genius
  • Start messing with the code/graphics etc. When this is done you should commit the changes to your branch, in your working copy. There are a few things you should do before committing to check.
    make clean slowtest
    git status This will show you which files have been changed/added/deleted
    git add -i A text UI to interactively choose what to add. Called staging for the commit
    git diff Shows you the changes line-by-line between what has been committed (HEAD) and what has been changed (excluding files that have been staged)
    git commit -m "A description of the change" Commit the staged files.
  • When you have done a little work, it is a good idea to back it up. This sends the new branch ("genius") to your GitHub fork ("origin"). The -u links your local working copy of the branch to the branch on your fork: the local branch is set to track origin/genius.
    git push -u origin genius
  • Do some more work and commit it. Be sure to keep checking status and diffs. To backup more work, due to the tracking, you just need to do git push to send the extra commits.
  • When the work of genius is ready (just after the last push), go to the rabbit-escape code page. It notices your recent push, and puts up a handy button to create the pull request. Review diffs again, type in some description and create the request.

Your next contribution

  • You need to update your working copy from the main repository. Create a link to the main repository from your working copy: a remote.
    git remote add upstream https://github.com/andybalaam/rabbit-escape.git
  • Then you can update your working copy with the work of others. You have called the main repository upstream, and you want commits from its master branch merged into your master branch.
    git checkout master So you pull into the correct branch.
    git pull upstream master Merge updates into your working copy.
  • Now you can start your next branch to fix a bug or make a feature.
    git checkout -b more-genius

Rabbot and Rabbit colliding