Assignment based on a branch

Suppose I keep a private repository for a homework assignment.
On the master branch I have a file with the exercises.
And on a solutions branch I have a file with the solved exercises.
Both branches have been pushed to the private repository.

Question: is it possible to create a new assignment based only on the master branch of the repository?

The motivation for this is:

  • Keep a single repository with questions and solutions
  • TA’s can access the private repository with both by being a member of the organization
  • Create assignments based only on the questions (master branch)

Thanks for helping!


So far I’ve noticed that there’s a full clone made from the repository linked to the assignment.
It would be a nice feature however to limit branches or even have a branch enforced where students work in.

I guess the easiest way to achieve this is to have two repositories. One with just the questions, which gets cloned by the students. And another with questions + answers, which stays private. This would require pushing the right branches to the right repositories.

1 Like

For the time being that’s indeed a possible way to handle things.
At least that’s how we’re doing it. One main (private) repo with the full solution, one repo that has the start files for the student in there.

For my “solution” repo, I pretend to be a student, accept the assignment invitation, and put my solution into the resulting repo.

My current solution is as follows:

  • Create two repositories: ProjectX and ProjectXSolved
  • On the local repository have two branches: master and solution
  • Add two “origins”:
git remote add origin url_to_projectX
git remote add solved url_to_projectX_solved
  • Work on assignment and when done push to ProjectX repo:
git push origin master
  • Work on solution and when done push both branches to ProjectXSolved repo:
git push --all solved

Since both repositories are private, I can create assignments based on the ProjectX repo, and the TAs can view the solution by cloning ProjectXSolved.
If you want to make the solution available to the students you can push all branches to the ProjectX repo after the deadline.

1 Like

As for homework, I found one resource to be extremely useful Just sign up for a student account. It helps when I’m in lack of time.