Homework Workflow

This guide demonstrates how to use GitHub plus SourceTree to submit your homework and keep your repository up-to-date.

Specifically, we will use GitHub as our code repository (where we store our code) and SourceTree to interact with that repository. If you are already familiar with command-line git, you are welcome to use that instead.

This is only required if you want to be able to update your repository from the master msan622 repository whenever a homework description is updated. Otherwise, you can just use the free GitHub for Mac or Windows client. (This client tends to be easier to use.)

Setup

Make sure you have a GitHub account and SourceTree installed. Both GitHub and SourceTree are free, and SourceTree is available for both Mac and Windows.

Fork

Log in to your GitHub account and go to https://github.com/msan622/msan622 to get started. Click on the "Fork" button at the top of the page:

Select your account if prompted. This should create a copy of the msan622 repository within your own GitHub account.

You should see your GitHub username instead of sjengle in the image above.

Clone

Clone the repository to your local computer. You can use the GitHub client for Mac or Windows if you prefer, or the git command-line tool. These steps will show you how to clone the repository using SourceTree.

In GitHub, you need to copy the clone URL for your the msan622 repository in your account. You are looking for something like this:

Make sure the "HTTPS clone URL" is shown and copy it.

In SourceTree, click the "Add Repository" button or select "New" from the file menu. Enter the clone URL and select where you would like to save the files on your local computer:

Click the "Clone" button and wait the for operation to succeed. Once it does, you will see something like this:

If you browsed to the folder you selected earlier, you will also see all of the files have been downloaded to your computer:

If you use git properly, any changes you make to those files will be reflected in your GitHub account. And, should your harddrive fail or your files become corrupted, you will be able to redownload the latest version of your files from GitHub.

Push

Go ahead and modify the README.md file you downloaded with your name, address, and short bio and save.

Note that these changes are not reflected in GitHub yet. This is because you must push your local changes from your laptop to the remote repository on GitHub.

In SourceTree, open up your msan622 repository/bookmark. Click on "Working Copy" from the window. You will see the README.md file in the section of the window titled "Files in the working tree":

Click that file and click "Stage File". This prepares the file to be committed. You can stage multiple files at once, and all of these will be included in the next commit.

Click the "Commit" button. You will see a window like this:

Briefly explain the changes you made in the "Commit message" and select "Push commits immediately to: origin". When ready, click the "Commit" button.

Now, when you check your repository on GitHub, you should see all of the changes you made.

Pull

If you want to update your files because the original msan622 repository was modified, you need to do a few things. This is the only operation that cannot be done using the GitHub for Mac or Windows client. You must use SourceTree or the git command-line tool for this operation.

In SourceTree, click on the "Settings" button for your repository. You should see a window like this:

Right now, SourceTree only knows about your version of the msan622 repository and not the master version you originally forked from. To change this, click the "Add" button to add a new remote repository:

Name the new remote upstream and enter the clone URL for the original repository under the msan622 organization. Click the "OK" button when done. You should now see both remotes listed:

It may take awhile to refresh, but eventually "upstream" will appear in the "remotes" heading on the sidebar. Select the "master" branch within that remote:

In this view, you will see changes in upstream/master that occurred after you forked the repository. Select the changes you want to merge into your repository, and select the "Merge" button.

Make sure "Commit merge immediately" is selected and click the "OK" button. At this point, we have merged together the changes on your local repository. Now we must again push these changes to your remote repository. Click on the "Push" button:

Make sure you are pushing to the origin remote repository and not the upstream repository. Press "OK".

At this point, you should have the changes in your local computer and in your remote repository on GitHub.