Question

Instructor wants students to commit their source code to github. Each student has his own repo. I don't have push access to student repos. I can pull their source code just fine, but I want to edit the code and add comments to help them improve their grade. Would like to submit this modified code to them in the form of a pull request. But I can't figure out how to do it. Played with forks and stuff but ended up with two repos for each student (one on github and one local)--really ugly. I know that this forum isn't really appropriate for asking for workflow suggestions, but I can't find a git help forum. Can anyone point me somewhere where I can get pointers from git experts?

Was it helpful?

Solution

Played with forks and stuff but ended up with two repos for each student (one on github and one local)...

This is how Git operates. You clone a remote repository, work on it locally, and push your changes back. If your remote repository is on GitHub, and originated as a fork of somebody else's repository, you can submit a pull request that will allow the owner of the original repository to review and possibly incorporate your changes.

So in general, your workflow would look something like:

  • Students creates their repository, does some work.
  • At some point, you fork the repository on GitHub.
  • You clone this repository to your local system, where you proceed to edit/comment/etc.
  • You push your changes back to your remote repository on GitHub.
  • You generate a pull request for the original repository.

Note that in this workflow, you have a point-in-time snapshot of the student's repository. That is, if they make changes after your work, they will not be automatically incorporated into your repository. If you want to pull in additional changes from the student, you would need to add an additional remote to your local repository and merge changes from that into your local branch. If you think you're going to want to do that: I would first get the basic fork/clone/edit/push/pull request workflow before tackling that, and consider opening that as a new question.

UPDATE

To pull new changes in the original repository into your fork:

  • In your local repository, run:

    $ git remote add upstream <original_clone_url>
    

    Where <original_clone_url> is whatever is displayed in the HTTPS clone URL field on the right side of the GitHub page for the original repository.

  • To bring in new changes:

    $ git fetch upstream
    $ git merge upstream/master
    

    This will merge changes from the "upstream" repository into your local repository. Then:

    $ git push
    

    To push these changes to your forked repository on github (from where you can generate a pull request when appropriate).

It turns out that GitHub has this whole process documented quite nicely here. If you haven't spent some time with http://help.github.com/, it's worth a few minutes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top