Skip to content

Using git in CS 491

(Adapted from the CS 225 version!)


git will be used throughout this semester as the version control system for course work. Specifically, we will use it for:

  • Distribution of grades.
  • Communication of problem sets during lectures.

You will not use git for turning things in; you will use the online judges for that.

While we do not require that you learn and use good version control practices, we cannot stress enough how useful a good version control system can be when good practices are used. The following is a brief list of good version control practices:

  • Always use a good commit message which describes the changes in the commit.
  • Never check in broken code. (This is more important when working in groups, but still good practice.)
  • Commit regularly and frequently. For example, commit when you’re done writing a function. This allows both simpler commit messages and greater confidence in the repository.

Again, the above practices are not hard and fast, nor complete, but they should help you complete your MPs and future coding projects should you use git for them as well.

Course Setup (necessary only once for the entire semester)

The first time you’re accessing the CS 491 repository this semester, you will need to have a CS 491 repository set up for you. This process is simple:

  1. Visit [[][]].
  2. When you view your repostiory, do not follow the instructions to create a README. Instead, just note the URL – it will be similar to

Workspace Setup (necessary only once per computer/directory you use)

Create a clone of your repository

To setup your computer to work on problem sets and communicate them to the instructor, you will need to clone your repository onto your comptuer.

The URL of your repository will be based on your NetID and you will need to replace NETID with your NetID.

To clone your repository, run git clone:

git clone cs491git

you can replace cs491git with whatever folder you want created. For example, you may want to call your folder just “cs491” or “cs491work” or anything else.

On some systems, git (and other command line programs) will not display anything when you type your password. This is expected: type your password as normal, and then hit enter.

Finally, move into the directory you just cloned:

cd cs491git

Add the release repository as a remote

To connect to the release repository, you need to add a remote:

git remote add release

Assignment Setup (necessary only once per assignment)

To retrieve the latest assignments for CS 225, you need to fetch and merge the release repository into your repository. This can be done with two commands:

git fetch release
git merge release/NAME -m "Merging release repository"

Don’t type NAME literally here; on each assignment we will provide the proper name to use.

If git happens to complain about unrelated histories, use this command:

git merge release/NAME --allow-unrelated-histories

Assignment Submission (do this often!)

Well.. you aren’t actually submitting anything. But a remote git repository serves as a wonderful backup tool. If something goes wrong and you delete your local copy, you can always restore it from the remote repository.

Every time you reach a milestone and want to checkpoint your work, you will need to add, commit, and push your work to your git repository. This can always be done using the following commands on a command line while within your CS 491 directory:

git add -u
git commit -m "file submission"
git push origin master

Verify your Submission

You can always verify your “submission” by visiting and viewing the files in your repository.