CS 240 Homework 1 - Getting Set Up and Introducting Git

Due Thu Sep 11 at 11:59pm

Overview

The purpose of this assignments to get you set up for the course, and get started with git and GitHub. Git is a version control system (used to organize source code when multiple people are working on it), and GitHub is a hosting service for organizing git-controlled projects.

This assignment will walk you through setting up git and GitHub for use in this course, give you a chance to use an online tutorial (you'll probably do that a lot in this course), and give you some practice making and submitting changes to a repository.

Assignment Objectives

Assignment Details

There are lots of pieces to this assignment (as you need to get setup with everything), but all of them should be straightforward. These will take some time--do not leave this until the last minute!

1. Setup the Bookware VM

The first thing you'll want to do is get a development environment setup for this course. Luckily, the textbook comes with a virtual machine image that contains all of the tools referenced in the text that we will use in the class. See section A.3 in the text for further details.

2. Configure Git and GitHub

The next thing you'll need to do is configure git and sign up for GitHub. More details can be found in section A.7 of the text.

3. Git Tutorials

At this point, you should be all set up to use git! But how exactly do you use this thing?

While we'll be going over the basics in class, another good way of learning a new programming language or tool is to take advantage of the many online tutorials and guides.

There are numerous tutorials for git available; for this assignment, you will be using and evaluating one of the online, interactive versions:

You are welcome and encouraged to look at the other tutorials--particularly if your assigned tutorial isn't helpful for you. But you still need to complete your assigned tutorial so you can evaluate it!.

4. Committing a Change

Now that you know how to use Git (right?), let's do something with it. For this part of the assignment, you will clone an existing repository, modify some files, and then push out your changes.

  1. Start by cloning the hwk1 repository (Note: all instructions in this assignment describe cloning via HTTPS. You are welcome to clone via SSH instead; generally you replace 'https://github.com/' with 'git@github.com:')
    git clone https://github.com/UPS-CS240-F14/hwk1
    • In the VM, you should probably do this in the "Documents" folder
  2. Switch into the hwk1 directory
    cd hwk1
  3. Create and switch to a new branch to do "development" on
    git checkout -b develop
    It may feel a little silly to make a separate branch for the small number of changes we're making, but it's good practice!
  4. Modify the class_list.txt file to include your name and information about yourself, following the format (if there are any questions, post them to Piazza!)
  5. You may want to backup your changes at this point by committing them
    git add class_list.txt
    git commit -m "<a descriptive message of your commit>"
    • Remember: commit messages should summarize what the commit does to the repo in less than 50 characters (you can add more detail on the following line). Use the imperative tense: "adds Joel's name to the list"
  6. Modify the tutorials.md file to add a review of the git tutorial you completed. This does not need to be extensive, but should include at least one thing that "works" about the tutorial and one thing that doesn't. You should also look through other people's comments, and expand onto them if you can. Our goal is to make a nice summary of these tutorials that may be helpful to others (e.g., future CS 240 students)!
    • This is the most involved part of this assignment.
    • Yes, using a Wiki might be more effective at achieving this goal, but we're learning git.
    • Similarly, you should make these changes using the command-line interface, rather than simply editing through GitHub.
    • Note that this file is formatted using Markdown
  7. Commit your changes to your local repository (see above)
  8. Merge your development branch back into your master branch. First checkout the master, then perform the merge.
    git checkout master
    git merge develop
  9. Before you push your changes back out to the rest of the repositoryFinally, you should push your changes back out to the rest of the repository. First, make sure to pull in anything that has changed since you began editing
    git pull
    and finally push the changes
    git push
  10. If you get any merge conflicts througout this process, you'll need to resolve them!

And that does it for this part of the assignment!

5. The Homework Repository

There is one last task to do for this assignment, and that is to get your system setup to turn in future assignments. Assignments will be turned in by uploading files to your own personal homework repository (that has been automatically set up for you). However, we have to do a little bit of work so that you can pull starter code from the group homework repo, but submit to your personal repo.

  1. First, clone the current homework repository, and then cd into it.
    git clone https://github.com/UPS-CS240-F14/homework.git
    cd homework
  2. Now we're going to change that local copy so it instead points at your personal repository. By default the remote called origin is set to the location that you cloned the repository from. You should see the following
    $ git remote -v
        origin  https://github.com/UPS-CS240-F14/homework.git (fetch)
        origin  https://github.com/UPS-CS240-F14/homework.git (push)
    We don't want that remote to be the origin, instead, we want to change it to point to your repository. To do that, issue the following command
    git remote rename origin upstream
    This changes the name of the remote from "origin" to "upstream". Now you should see the following
    $ git remote -v
        upstream  https://github.com/UPS-CS240-F14/homework.git (fetch)
        upstream  https://github.com/UPS-CS240-F14/homework.git (push)
  3. Now we just need to give the repository a new origin---namely, your personal homework repo!
    git remote add origin https://github.com/UPS-CS240-F14/hwk-<ups login here>.git

    Remember to substitute in your UPS id!

    Once it's set up, it should look something like

    $ git remote -v
        origin  https://github.com/UPS-CS240-F14/hwk-<ups login here>.git (fetch)
        origin  https://github.com/UPS-CS240-F14/hwk-<ups login here>.git (push)
        upstream  https://github.com/UPS-CS240-F14/homework.git (fetch)
        upstream  https://github.com/UPS-CS240-F14/homework.git (push)
  4. Test out your setup by pushing your local repository out to your personal repository on GitHub
    git push -u origin master
    You should see something like:
    Counting objects: 7, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (6/6), done.
    Writing objects: 100% (7/7), 1005 bytes | 0 bytes/s, done.
    Total 7 (delta 0), reused 0 (delta 0)
    To https://github.com/UPS-CS240-F14/hwk-jross.git
     * [new branch]      master -> master
    Branch master set up to track remote branch master from origin.
    Note you only needed to specify the remote when pushing once (to setup remote tracking branches). In the future, you can just push
    $ git push
        Everything up-to-date

Now you're all setup! Using the homework repositories is pretty simple.

Submitting

Successfully committing and pushing the required changes to the hwk1 repo and your personal homework repo on GitHub counts as a submission of this assignment. Remember to push your changes to GitHub!

Grading

This assignment will be graded out of 10 points: