Skip to content

Coder Intro Part 1: Git

Barley edited this page Oct 15, 2017 · 22 revisions

(if you already know Git you can skip to the next part)

For those unfamiliar with Git, it is a version control tool which allows groups to easily collaborate on software projects. It's essential that you get to grips with using it if you want to code a microgame.

GitHub

GitHub is a handy site for storing Git repositories. It's what we use to keep NitoriWare secure and public. If you don't already have one, make a GitHub account here.

Git

Git itself needs to be installed in some form on your computer. You have a couple of options here:

  • Command line client: Git is available for Windows, Mac and Linux and can be downloaded from the Git website. It will allow you to open up Git command line terminals anywhere on your computer using the context menu.

  • Desktop client: GitHub provides a very handy desktop client which can be much simpler to use than the command line. For the purposes of this tutorial you are welcome to just use the desktop client. However, please make sure you read the section on keeping your fork up to date in Part 5, since there are some limitations to the program.

Learning Git

This tutorial is very helpful if you want to learn how the various git commands work: try.github.io

If you get stuck with anything, don't hesitate to ask for help. Git can be pretty frustrating and unintuitive and it's very likely that others will have run into the same problem before.

Getting started

1. Fork NitorInc/NitoriWare

On GitHub, fork the NitoriWare repository by pressing the "Fork" button in the top right hand corner of the page. If you're not sure what this is doing, feel free to read up about forks here. For now, we'll assume it went OK and you're ready to move on.

What you should have now is a copy of the project under your own GitHub username. The URL should look like this:

https://github.com/YOUR-USERNAME/NitoriWare

This is what you'll be working with when coding your game. However, while you can make small modifications to the project on GitHub itself, in order to add microgame code you're going to need to clone this repository using Git.

2. Clone your repository

Now that you have a Git client (either the desktop program or a command line), you can go ahead and clone (Git speak for download) NitoriWare to your computer. Go to the GitHub page you were at earlier (making sure it is your own fork of the project and not NitorInc/NitoriWare) and then press the green "Clone or download" button in the middle right of the page.

You should see a pop-out that says "Clone with HTTPS" and a URL. Copy that URL into to "File > Clone repository..." for the desktop client, or type: git clone https://github.com/<username>/NitoriWare.git if you're on the command line (making sure you've opened Git bash in the directory you want to keep your code in).

Now you'll have a folder containing all of the NitoriWare code. This is, in fact, a Unity project. But before we open it up, lets create a branch for our changes.

3. Create a branch

We're now going to create a branch in our repository. This will let us add our own changes without affecting the main repository branch.

In preparation for the ReimuDodge microgame coding tutorial, we'll call this branch after the NitorInc convention for new game branches: "Microgame/ReimuDodge/basic-functionality"

On GitHub Desktop

Make sure your current repository is NitoriWare and select Branch > New branch... and call it "Microgame/ReimuDodge/basic-functionality". Then, just click the "Publish branch" button and the new branch will be copied to GitHub and automatically set up for pushing new commits.

On the command line

Making sure your Git command line client is open inside your project folder, type: git branch -b Microgame/ReimuDodge/basic-functionality. The "-b" options tells Git that we want a new local branch. Now we need to push this branch to your repository on GitHub using: git push -u origin Microgame/ReimuDodge/basic-functionality. This does two things: First, it sends information about the new branch to "origin", or your GitHub repository (try doing git remote -v to see). Secondly, the "-u" options tells your local Git client that, from now on, any commits to the basic-functionality branch should be pushed to the same branch on GitHub.

That's it. Now you should be able to see your branch by going to your fork on GitHub and clicking the "Branch" drop-down on the left (the default branch is "develop").

Side note: Switching between branches can be confusing. Just remember that it's generally a good idea to commit and push all of your current changes before moving branches.

Next up, Unity.

Clone this wiki locally