0

In this semester, we are using Git for students to do their assignment. Basically, we set up a bare repository on a central server for every student, which includes the skeleton code for the assignment. Students then can clone the project, do the assignment, and push back changes to the server.

However, sometimes after we've created the bare repositories (and students may have already pushed changes), we found the assignment itself may need to be changed, and thus we find it necessary to update EVERY student's bare repository. So far, we don't have any good way to this.. I just want to know what is the best solution for this problem, so we can minimize the work (especially for students, who may not have used git before).

Thanks!

Chao Sun
  • 655
  • 1
  • 6
  • 16
  • Every single student has their own remote fork of a bare repository? –  Sep 04 '13 at 02:06
  • You got the code there without git to begin with - why not repeat that process? Or do you want the changes to be visible as part of the repo? – Chris Hayes Sep 04 '13 at 02:08
  • @ChrisSun please also explain in what way an assignment needs to be changed. Can the students themselves update the assignment on their remotes via a fetch and pull? Do you want to update the assignment between semesters, or during the middle of one? Were you planning on updating the assignment then committing the change, or did you want to have a completely new repo? –  Sep 04 '13 at 02:12
  • @Cupcake: yes, sort of. We make separate bare repos for them. They then clone the repo and do work. – Chao Sun Sep 04 '13 at 02:14
  • @Cupcake: for instance, sometimes we found test cases are not exhaustive, then we need to add a few more test code into assignments, and we want to push this change to every student's bare repository. – Chao Sun Sep 04 '13 at 02:19

2 Answers2

0

If you don't mind having students update their local repos and remote forks, then you can update a single remote repository and have each student fetch from it, merge in the changes, then push to their own forks.

Here are the changes that you need to make for your remote:

# Add some changes, then commit them
git checkout master
git add .
git commit -m "Update assignment"

and here is what each student needs to do:

git fetch remote
git merge remote/master
git push personal-fork head

Alternatively, you could write a script (in something like Bash, PHP, Perl, Python, Ruby, etc) to add each student's remote to a single repository, then push the changes to each student's remote.

  • I think first solution may need to much work for students. Students only know how to use EGit, and merging in EGit is hard to use. For the second solution, what if students already made changes to their corresponding remote? Will that cause any issue? – Chao Sun Sep 04 '13 at 02:28
  • You could always supply instructions for how to merge from the command line. I'll add them to my answer. –  Sep 04 '13 at 02:29
0

I would recommend instructing students to leave their master branch untouched, as it may be overwritten by teachers at any time. Their changes for any particular assignment should always be done on branches, and periodically rebased against the latest changes in master to make sure they're working from the latest version of tests and such.

On the administrative side, in your main working directory you can define a remote with every student's repo: https://stackoverflow.com/a/4255934/54249. When you need to share changes, a force push to each student's master branch should do the trick.

Community
  • 1
  • 1
dahlbyk
  • 75,175
  • 8
  • 100
  • 122