Skip to content

GitHub Classroom creates a repo based on the specified template - syncing changes between the two #149

@sgbaird

Description

@sgbaird

https://chatgpt.com/share/67c0233e-a684-8006-a5a9-41affa40cf8d

After creating a codespace (or cloning locally) for the private repo (the one that GitHub Classroom autogenerates when the instructor first creates an assignment):

git remote add upstream https://github.com/template-owner/template-repo.git

Verify the remotes:

git remote -v

Which should look something like:

origin   https://github.com/your-username/your-private-repo.git (fetch)
origin   https://github.com/your-username/your-private-repo.git (push)
upstream https://github.com/template-owner/template-repo.git (fetch)
upstream https://github.com/template-owner/template-repo.git (push)

Fetch the latest from the template repo.

git fetch upstream

Merge.

git merge upstream/main --squash --allow-unrelated-histories

Resolve the conflicts by right clicking on each file in the Codespace source control sidebar that has an exclamation mark icon, and selecting accept all incoming. Remember to save the actual file in the editor. Do this for all files (assuming you haven't made any changes on the autogenerated file that you want to keep, otherwise use merge editor), and then stage all files. NOTE: The merge conflicts should have gone away. If you haven't saved all the files, then it will likely throw a warning or error. Don't commit if there are still unresolved merge conflicts. Finally, commit the files and sync.

Back in the GitHub Classroom interface for the assignment, you'll click "sync assignments. After "sync assignments" via GitHub Classroom, then there might be merge conflicts on some of the student repositories. If the student has already started working on the assignment, things get tricky. If only files other than the ones the student should be editing are changed, then the solution seems to be to open that PR, manually look through the edits, and merge. If the student has started working on the assignment, then instead of merging the PR, you'll manually apply the changes directly to the main branch (not in the context of the PR) and then close the PR. This has to do with the fact that if you edit the file, the changes would go back to the autogenerated GitHub Classroom assignment repo (private template repo), which isn't what we want.

If the student hasn't started working on the assignment, hopefully these have the "resolve in editor" button (i.e., without needing to clone or go to a codespace) when navigating to the pull request, at which point you can generally accept current for wherever the student's solution has already been applied, though there may be some cases which require special attention. The issue is that this process will need to be taken care of for each repository this applies to, either by the student or by the instructor. It may not matter as much for students who have already completed and passed an assignment, unless that assignment grade is directly passed via API to the learning management system (right now, it's a manual self-report).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions