Wednesday, September 14, 2016

Using GitHub for Homework Submissions

I teach a course in Windows programming. I use Visual Studio. All programming projects are team projects. I have eight teams, with a repository for each team.

Each group in my class has four or five students. Four seems to be the best number, since it is harder to arrange a meeting for five people. For each group, I created a team in GitHub.

Each student must create a GitHub account and send it to me, then I invite them to the team.

I created eight private repositories in GitHub, so only an authorized team has access. The repository is for all the homework assignments. Each repository has one team assigned to it.

The master branch in the repository only has a README file. The file indicates that each homework assignment will be in a separate branch. I populate the branch with a Visual Studio solution.

Once the student, X, has accepted the invitation to the team, X will be able to view the repository in GitHub. The repository has a button for "Clone or Download". Clone is the preferred method. The URL to use to clone the repository is displayed. X should copy the URL and open Visual Studio.

In Visual Studio, X should open Team Explorer. Look for the icon that looks like a plug. It is for Connections. Open it and look under Local Git Repositories. Click the Clone drop-down indicator. Paste the URL from GitHub and click Clone.

After the repository has been downloaded, click the Home icon to go the home screen. On the home screen, click the Branches link. Near the bottom of the screen are the Active Git Repositories. Open the remotes/origin link. Select the branch for the current homework.

Once the correct branch is selected, return to the Home screen. At the bottom, under solutions, should be the homework solution. Double click it and the solution files will be opened in Visual Studio. Open Solution Explorer and start modifying the file.

After making edits, return to Team Explorer and select Changes. Commit All the changes and Push at the same time.

Before starting a new editing session, open Team Explorer, select the solution, and Sync to the remote server.

To populate with an existing solution,
In GitHub,
  1. Create a branch for the assignment in the repo on GitHub
In VS,
  1. Create a new local repo. 
  2. In the local repo settings, set the remote address to the clone address for the remote repo.
  3. Return to Home and select Sync
  4. Perform a fetch to get the hw branch.

The Open solution option in the local repo will only work if the repo is empty. To circumvent,
  1. Open File Explorer and navigate to the repo folder. 
  2. Copy the initial folder that contains the solution into the folder.

Back in VS, the solution will now appear in the local repo.
  1. From Home, select Changes and Commit and Push to commit the .git files
  2. Double-click the solution to open it.
  3. From Home, select Changes and Commit and Push to commit the .git files

Later, I wanted to update the repository with the next version of the submitted homework, since not all students chose to use the repository. Many changes had been made since the initial contents.

I created a branch in GitHub for me from the initial state and sync'd it in VS. Then I opened the new solution in VS. From Home I viewed Changes and committed and pushed to GitHub. In GitHub, I performed a pull request into the original branch from the new branch. No conflicts were present, so the merge was possible. 

No comments:

Post a Comment

Followers