Using git and github for course assignments

Here’s my tested plan for using git and github to manage student assignments for my upcoming course.

Initial setup as the instructor:

We’re going to create a student repo and an instructor fork for each assignment. The motivation for separating assignments is to ensure that the diffs that students are submitting for their solutions are tidy. In my case, there’s not much shared code between assignments

Create public* repo that students will see: test-gp-hw0-student.

If you try to fork this on Github, it will tell you that you already have a fork. So instead trick github into forking it via the github importer, import test-gp-hw0-student as a private test-gp-hw0-instructor. Now you have two repos. We’ll set up a branch on test-gp-hw0-instructor to track test-gp-hw0-student for easy merging:

git clone$INSTRUCTOR_REPO.git
git remote add student$STUDENT_REPO.git
git fetch student
git checkout -b student-tracker --track student/master
git checkout master
cd ..

To test this out, let’s create a file visible to everyone (students and instructors) in the student repo:

git clone$STUDENT_REPO.git
echo "visible to everyone" >>
git add
git commit -m "add file visible to everyone"
git push
cd ../

Now, let’s merge change into the instructor repo

git checkout master
git pull student master
cd ..

Just to be thorough, let’s try the reverse: creating a file just visible to instructors:

echo "visible to just instructors" >>
git add
git commit -m "add file visible to just instructors"
git push
cd ..

Getting assignment and handing in assignment as the (dummy) student

Open an incognito/private window and create a new github account for a fake student (pro tip: gmail lets you put dots anywhere in your email address so that redirects to, but most websites don’t recognize that these are the same). My fake students name is stewartdent.

Clone the repository and try to access the instructor repo (assuming the url was leaked):

git clone$STUDENT_REPO.git stewartdent
cd stewartdent
git remote add instructor$INSTRUCTOR_REPO.git
git fetch instructor

You should see an error:

remote: Repository not found.
fatal: repository '' not found

Now, let’s act as the student to submit the homework

# cd stewartdent
echo "stewartdent was here" >>
git add
git commit -m "Stewart Dent's Assignment 01 submission"
git push
cd ..

The student has pushed their submission onto their own repo. They can continue to work on it using git in all its glory. When they’re down they “hand in” their homework via a pull request onto the public test-gp-hw0-student repo. The student does this by visiting the Github page for their own fork of test-gp-hw0-student and clicking “New Pull Request”.

Grading as the instructor

The instructor can now grade this. I’m imagining that the test-gp-hw0-instructor repo has a solution that can be compared (in some way or another) to the students work. To pull the students work into the instructor copy (but never merge):

git checkout -b stewartdent-master master
git pull master
# Record grade.
git checkout master
git branch -D stewartdent-master

Then the instructor can close the pull request on test-gp-hw0-student.

Other perks

Questions or discussions related to the homework can be conducted on the “issues” page of test-gp-hw0-student

* The fact that this repo is public should immediately indicate that student’s work submitted via pull request will also be public and importantly will be visible to other students. Unlike the most common form of cheating, this means that Student A can copy the work of Student B without the explicit consent of Student B. Student B’s only possible defense against this would be to submit their work just before the deadline. As far as I know, I can’t hide pull requests from the public (that would be a nice solution) and I prefer not to use any method that relies on student’s having to create a private fork (since they cost money; although, other class require very over-priced textbooks, so a 6-month github subscription is not so crazy, but it does go against the open-source spirit; there’s also the Big Tobacco style get’em while their young

Tags: ,

Leave a Reply