Turning in assignments with git and GitHub


We will use the repository tools git and GitHub.com for assignments and submissions. This will allow you to practice using the most common repository tool. Repository tools are now often required for submitting companion code for journal articles and are also critical for sharing code with other users around the world and tracking changes. It will also allow your instructors to more carefully analyze each student's results so we can tailor our time and resources better for each student. 

The assignments are available on the Problem Sets pages, and the Lab responses are available here.

You can also watch a video on Using git and GitHub.

What is git? What is GitHub?

git is a file repository tool. It saves information about which files comprise the repository and all of their past revisions (versions) in a tiny directory called .git in the directory of your repository. It can be used to restore and update files. 

GitHub is a cloud-based service that allows you to store and distribute your repositories across the internet. It is accessible over the web at GitHub.com.

We will guide you through the completion of a simple assignment called Bio107_ps_0_0. You can use this to practice using the submission system.

Step 0: Ensure that git is installed on your computer

If you have a Mac, it is installed already. You can verify that it is installed by opening the program Terminal and typing git on the command line. You'll see a list of the git options.

Step 1: Accept the assignment in GitHub classroom

There are a few parts to "accepting" and downloading the assignment. It isn't quite as simple as downloading a directory, but once you get used to it, you will understand the basic concepts of a file repository.
  1. Accept the assignment: Each assignment has a web link to accept. Click on the link provided. As an example, here is the link for Bio107a_ps_0_0.  When you accept the assignment, a repository is created that has a set of template files and other data needed to complete the assignment.
  2. Download ("clone") the repository onto your local computer
    1. Open a command line on your system. On a Mac, open the application Terminal. On Windows, run the program command.com
    2. Navigate to where you will store your files: using the command cd (change directory). For example, on a Mac, you might type cd /Users/MYUSERNAME/Documents/MATLAB/Bio107a.  If the directory does not yet exist, you can create it by typing mkdir /Users/MYUSERNAME/Documents/MATLAB/Bio107a.
    3. Clone the repository on your local disk: type git clone https://github.com/bio107afall2019/yourrepositoryname such as git clone https://github.com/bio107afall2019/bio107a-ps-0-0-stevevanhooser

Step 2: Complete the assignment by editing the files


Now you have the files on disk. For most assignments, the instructions are on our own web pages (linked in the README file). For Bio107a_ps_0_0, each question folder has an assignment.md file in it that you can open with any text reader, or you can view it on the GitHub website.

Edit the .m files for each question as in the instructions. Edit the response.md file so that your written responses are recorded in the spaces indicated. This file is in markdown format but can be edited by any text editor (SimpleText on a Mac, NotePad on a PC; or use the Matlab Editor). Please do not edit the # QN.M  lines, because we will use these to help us grade.

It is particularly important to edit the identity.txt file to include your name, Brandeis email address, and the names of your collaborators. 

Step 3: Commit your changes and post them back to the remote repository

There are 2 steps to posting your changes back to the cloud distribution. The first step is to commit your changes. It is a little confusing at first, but the files that are on your disk are NOT the distribution on your disk itself. In order to update the distribution (on your local disk, that is, the information in the .git directory) to match the files that are there, you need to commit the changes on your file system to the distribution. Then, you push the changes back up to the cloud.
  1. Commit your changes: In the Terminal or command.com program, navigate to your repository (for example, on a Mac: cd /Users/MYSERNAME/Documents/MATLAB/Bio107a/bio107a_ps_0_0). Then type git commit -a -m "my changes". (You can add your own comment instead of "my changes").
  2. Push your changes to the cloud: Type git push, watch it upload (perhaps entering your GitHub username and password), and you're done.

Step 4: If on a public computer, delete your local directory

If you are on a public computer, you should remove the directory.



Comments