Working with GitHub

Create a new repository on GitHub and import your code.

  1. Go to GitHub.com and create a free account.
  2. Click on '+' at the top right and then on New Repository.
  3. Give your repository some useful name, such as "os161".
  4. Click on "Private" just below the "Description" box. Do not miss this step! You won't want free riders stealing your code. We will not accept assignment submission from repositories that are public.
  5. Click on Create Repository.

    Next you will see a page explaining several ways of creating repositories.

    You will see instructions to create a new repository on the command line, which look something like this:

    echo "# os161" >> README.md
    git init
    git add README.md
    git commit -m "first commit"
    git branch -M master
    git remote add origin https://github.com/username/os161.git
    git push -u origin master
    

    Let's get follow them step by step.

  6. First, let's get some actual code that you will push into your new repository. Log on to the machine where you have the os161 tools installed. If you are using your virtual machine appliance, start it up, if you are using the department server, log on via ssh: ssh ece-username@ssh-ubuntu.ece.ubc.ca. If you installed tools on your own Mac or Linux machine, just open a terminal and go to your home directory.

    Create a directory, where you will keep your os161 source code and environment.

    mkdir os161
    mkdir os161/src
    
  7. Download and unpack the code archive:
    wget http://people.ece.ubc.ca/os161/download/os161-CPEN331-base-2016.tar.gz
    cd os161/src
    tar -xvzf ../../os161-CPEN331-base-2016.tar.gz
    

    You should see a directory structure like this, if you type ls:

    ssh-linux2:~/os161/src> ls 
    CHANGES common configure design kern Makefile man mk userland
    
  8. Now initialize the local git repository and set up the remote, using the URL given to you by GitHub:
    git init
    git remote add origin https://github.com/username/os161.git
    
  9. Tell git to keep track of all the files in your os161 directory, commit the files and push them to the remote server.
    git add *
    git commit -m 'Initial commit of os161 for CPEN331'
    git push -u origin master
    

    To complete the last step, you will be asked to enter the GitHub password. To avoid typing your password every time, you can instruct GitHub to use your ssh key. First, add an SSH key to your GitHub account, as shown here. Next, switch the URL of your from HTTPS to SSH as instructed here.

Congratulations! You have created your CPEN331 git repository on GitHub!

Don't worry if you did not completely understand all the steps that you took with git. You will be learning and using git throughout the semester and will become very familiar with its commands.

IMPORTANT: Give us permission to read your repo

You need to give your instructors the permission to read form your repository so we can grade you assignments. Follow the instructions here.

Additional configuration

Finally, to correctly track the user committing the code, run the following commands:

git config --global user.name "Your Name"
git config --global user.email "yourname@server.ca"

Create another clone

Now you have a copy of your repository in the ~/os161/src directory on the ssh.ece server. Suppose you wanted to have another clone, either in another directory on the ssh.ece server or on your virtual appliance. Follow these steps to set up another clone:
mkdir another-os161-clone
cd another-os161-clone
git clone https://username@github.org/username/os161.git src

You need to use the same URL as in the steps above, the way it was given to you by GitHub. If you ever forget what it is, you can always recover it by going to GitHub.com, clicking on Repositories on the top menu, selecting the repository of your choice and copying the URL from the box in the top right corner.

Merging conflicts

Read this tutorial to assist you in your first merge assignment.