Updating assignments after creation?

I posted an assignment earlier than I should have, and a bunch of my students have already accepted the invitation. However… my starter code needed some work, and I would like to update the starter code. I thought the student repos would be forks of my starter code… but they’re not. So I don’t think they can git pull upstream or similar. I see @djholt suggested a manual command-line pull in this thread. Hmm. Is that still the recommended solution? I will get students to do this if necessary, but I’m worried there will be a lot of grief if I do. What have other people done?

As always, thanks for the help!


I often have to add additional information for assignments after the fact, and the only way to do it without deleting the assignment is to manually make the changes to each repository. I recommend using something like this mass clone utility to retrieve each repository and then use something similar to this addfile.py script to add the updated file, commit and push.

Note that addfile.py script is rather hacked together, I know it works perfectly on my machine but I can’t guarantee it will on yours.

1 Like

ah, those two scripts are great, thank you @ccannon94. Just used those two tools to push the update, it worked great.

addfile.py requires python2, so I just had to execute explicitly with python2 addfile.py to get it to work on Arch Linux.

1 Like

If you want to run it as a executable, you can add this hash bang to the top of the script /usr/bin/python2.


@titaniumbones Matt, hopes this answers your Qs.

Thanks to students and Campus Experts @JohnPhamous and @ccannon94 :sparkling_heart:

I have students add my master repository as an upstream repo, so they can pull changes automatically. I provide a script in the base directory that looks something like this:

#! /bin/sh
# Type ./update to run this file
git add remote upstream "..."
git pull upstream master

If there are downsides to this, let me know. I’m still new at this.

1 Like

I was thinking of doing something like that, instead of the addfile method that @ccannon94 uses above – if only to keep the git history in sync with the master repo. Anyway, yes, my question is more or less answered, and I hope to cobble together some scripts in the next day or so and share something a little more systematic in my other thread

1 Like

If no student has accepted the invitation yet, can I edit the assignment still? Or is the best solution to simply delete the repo and recreate the assignment from scratch?

1 Like

A student and I tested just this some 30 minutes ago on her machine and faced the following issues.

  • git commands like add or commit fail right after git pull upstream master. The error message complains about the inability to write to .git/index.lock and suggests that some other git process may be running. We could not find any other running git process. The fix we found was to manually delete the .git/index.lock file.
  • Only changes made in the upstream repo after it has been added are pulled. For example, imagine the following time line.
    – Time A: You release the assignment and the student accepts.
    – Time B: You make changes in your repository.
    – Time C: She does git add remote upstream "..." followed by git pull upstream master
    She will not get the changes from Time B as they were made before she added the remote upstream.

These issues make this otherwise attractive option unworkable. If anyone has fixes, please share.

Same here! All this time I had been making changes in my repository and asking them to git pull. I just now learned that what the students actually did was to copy the files I told them I had changed from the assignment repository (which was thankfully public) to their own.

She will not get the changes from Time B as they were made before she add ed the remote upstream.

Is this something that has been fixed in the meantime or can someone confirm this behaviour?

So today was the day I also tried out the workflow of updating my assignment after creation. I asked students to add another remote to their own repositories that points to the template repo (git add remote upstream ...) and then to fetch (git fetch upstream). Strangely, this did work for some students, for others it did not (they got a “fatal: failed to fetch from …”). Anybody has an idea why?

Also, while trying out myself (I created a fake student account and enrolled in class with it), I found that I was actually able to push also to this new remote upstream! I am worried that some student might actually accidentally do that and push his solution to my template. Why is this even possible? Any advice on how to guide the students not to do that (maybe give them some command to set up the upstream just with pull/fetch access?)

Anybody? Having this issue resolved would be a huge benefit for my class.

Hi @neumannm sorry for responding so slowly – this is a pretty structural issue in GH classroom, and the only way I know of to accomplish this is to write a script that submits a PR to all the student repos, or altenratively grabs al lthe student repos, applies a patch to the relevant files, merges the changes, and then pushes them to GH. Both are clumsy and error-prone. I think it would be quite difficult in a very large class to do this.

I don’t know why the students were able to push to the upstream. It is likely a permissions issue in the organization you have set up for the course.

Hi @titaniumbones, thanks for your reply. I understand that it’s a structural issue, still I am very confused that for some students, the “add starter repo as upstream and pull from it” method worked, and for others it didn’t. Anyway this approach is obviously unreliable, so we will find other workflows next semester.

Regarding the issue with some students being able to push to upstream, I have no idea which permissions I could have set wrong. The base permissions in the organization are set to “None” and I don’t find any additional setting that could have caused this issue.

Sorry for the late reply. I was in this situation again recently, i.e. I needed to edit the assignment files after the students had accepted it. Luckily, GitHub Classroom shows the student repositories created so far. I went to each one individually, made changes in it on the GitHub website (the changes were minor), and then committed the changes on the GitHub website. Good thing that instructors have admin access to the student repositories.

In my case, the repositories were few and the change was minor. Otherwise, this workflow can be made more efficient through a script as @titaniumbones has suggested above.

Just another note to say that, if you choose to use the new template repositories, then updating becomes rather more complex again, because the new student repos won’t share any git history with the old repository. Oops! this is messing things up a bit for me as we speak :-/

I was just testing this out, and, like you, I got a message about unrelated histories, presumably because I used the new template repositories. While I am testing this with a dummy student account, this appeared to solve the problem:

git merge --allow-unrelated-histories
git push

ah, that’s nice. I realized the other option was to just copy the changed files from the upstream repo into the student’s repo and create another new commit. Since I am mostly changing instructions or tests, there’s very little chance of messing up student work that way.

@neumannm you can protect your master branch of your assignment repo by going to settings -> branches -> and adding a rule to protect against inadvertent changes to the master branch. So if somehow someone does push changes to your repo, at least you’ll know master wasn’t affected.