Designing a generic repo for different uses

I have a private repo which contain some modules that help me grade student assignments in a programming course.
The repo has multiple generic files such as a student database builder, a module that runs the student’s assignment etc. It also has files that are exercise dependent such as HW_1 specific test variables, specific grades etc.

On one side, half of the modules are generic and i reuse them more or less exactly the same each time i grade a new assignment.
On the other side, when i start grading a new exercise i always change the specific modules to adjust them for the specific assignment i’m grading. which causes for a loss of older specific modules from previous assignments.

What would be a good design for the repo (or possibly repos) that will allow me on one hand to clone the files i need for repeated use but will also allow me to update the specific files without losing previous ones?
Right now, for each exercise i open a new repository which contains the generic files and then i update in it the specific files and when i’m done with the exercise the repo stays idle for a long while. This also results a large number of repos that i open that share a lot of common code but also has some specific code in it.

I’d be happy to hear your thoughts and suggestions towards a more efficient and elegant solution for this situation.

A number of things come to mind (not all of them compatible with each other):

  • Use branches instead of new repository copies, and optionally git worktree to check out those branches in different directories from one repository. This wouldn’t really change your workflow, just avoid duplication.

  • Move the shared tools into a separate repository. You could then either install them globally to use them independently from the repositories, or pull the shared tools repository into the assignment-specific ones as a submodule.

  • Minimize the degree to which you need to adjust the tools for specific assignments. I don’t know to what degree you might already have done that or how far it’s possible with the requirements, but in the long run it’s probably easier if you just need to update a configuration file or add a plugin script instead of adjusting code from a template.

1 Like

Thanks, you’ve certainly given me some food for thought.
I’m not familiar with the work-tree and submodule options but ill explore them.
Your 3rd advice is important as well and i already try to minimise the dependencies as suggested, but there’s probably always room for improvement.

1 Like