Creating and Submitting Assignments with Github

Setting up GitHub

We will be using GitHub Classroom to manage homework submissions. Please sign up for a GitHub account at if you do not already have one. This is the account you will use to create and submit all of your assignments this semester.

Please fill out the Google Form to provide your GitHub username to us.

Developing an assignment

1. Create a git repo for the assignment

Log in to your Github account. Then click on the assignment link on Piazza. This will create a repository on Github for the assignment. Make sure that the repository is called ECEDataScience/[assignment name]-[your username here]

2. Clone the repository

Cloning a repository creates a local copy. Change your directory to whichever directory you want to create your local copy in, and type:

> git clone[assignment name]-[your username here] [assignment name]

See below for instructions to clone your repository using SSH instead

This will create a subdirectory called [assignment-name], where you will work on your code.

3. Periodically commit your changes

As you develop your code, you can commit a local version of your changes (just to make sure that you can back up if you break something) by typing:

> git add [file name that you want to commit]
> git commit -m "[describe your changes]"

To copy your changes back to Github (to make sure they are saved if your computer crashes, or if you want to continue developing your code from another machine), type:

>git push

If you do not push, the teaching staff cannot see your solutions.

Submitting an assignment

Once you have a version of your program that you want to submit, tag the current version of the code with the tag submission:

> git tag -a submission -m "Submission for [assignment name]"

And push it to GitHub:

> git push --tags

If you want to update your submission (and tell the grading system to ignore any previous submissions) type:

> git tag -a -f submission -m "Submission for [assignment name]"
> git push --tags

This will overwrite any other tag named submission with one for the current commit.

Using SSH and GitHub

This is the method I prefer for accessing GitHub. Once you have this set up, you will never have to enter your username or password when accessing GitHub from your Scholar account.

SSH Keys

Normally when you use SSH, you have to enter your password. However, SSH has an alternate mode of authentication that uses public/private key pairs. You generate a private encryption key that you keep stored in your ECN account (no one but you can use it), and give your public key (that anyone can see) to servers that you want to SSH to. When you SSH to that server, your private key will be matched up with your public key to give you access.

Generate your public/private key pair

If you have not already generated a key pair for your ECN account, the following procedure will generate a key pair in ~/.ssh/. First, run the command:

> ssh-keygen

Hit enter three times (to accept the default location, then to set and confirm an empty passphrase). This will create two files: ~/.ssh/id_rsa (your private key) and ~/.ssh/ (your public key)

Copy your public key to GitHub

First, print out your public key:

> cat ~/.ssh/

Copy the result to the clipboard. Then follow steps 2–8 here.

Use SSH to access your GitHub repos instead of HTTPS

The various GitHub instructions for the course tell you to access GitHub repos using URLs that look like<path to git repo here>. This will access GitHub using HTTPS. To access GitHub using SSH instead, use URLs that look like<path to git repo here> (It seems weird to have that bit in there, but it's necessary.)

For example, Homework 1 tells you to clone your repository like this:

> git clone<your username here> homework1

Instead, to use SSH, you would clone your repository like this:

> git clone<your username here> homework1

Note: if you go to the webpage for your GitHub repo and click the "Clone or download" button, there will be a link in the upper right hand corner named "Use SSH." Clicking that link will generate the SSH URL you need for your repository.