Git and GitHub Setup (Project 0)

Do not do these steps before 2017-01-13! The repos won't be created until then.


Below are a set of steps you should follow in order to setup GitHub in your CSE Account. You should be able to work through these in order, and they should be must be connected via SSH one of the CSE linux machines such as or

You MAY do all development on your own machines if you choose (and can use a GitHub GUI). However, even if you do not develop on the CSE machines, these instructions will simplify testing your code there to make sure it works (as that is where all testing will be done).

This is a demo project to learn git, and as such, is not worth any points.

Setup secure connections between your CSE account and GitHub

First, SSH to either or using terminal (on a Mac / Unix) or Putty (on Windows). Instructions here:

Here is a full guide to generating a key for using SSH; this key will allow you to securely use ssh and, in particular, make use of GitHub without having to repeatedly type your password:

In short, you should:

  1. Generate a key (assuming you haven't already) by typing:

    ssh-keygen -t rsa -C ""

    (You should keep hitting ENTER to accept the defaults.)

  2. Go to your GitHub account
  3. Click on Settings (it's a gear icon in the upper-right corner of the screen)
  4. Click on "SSH keys" (in the list on the left-hand side.)
  5. Click on "Add SSH Key"
  6. Name this SSH key. If it's the one for your CSE account, you might want to set the title to "CSE Account".
  7. From your CSE account copy the full contents of the file ~/.ssh/ into the "Key" field. You can use: cat ~/.ssh/ Then copy to GitHub using the clipboard. Be sure to copy all of the contents of the file.
  8. Click on "Add Key" to indicate you are finished. The system may ask you to confirm your GitHub password.

To test if this whole process worked, go back to the command line in your CSE account and type: ssh -T

The system will likely ask you to confirm you want to connect. When you do, it should give you a positive confirmation if all went well, saying something to the effect of:

Hi ! You've successfully authenticated, but GitHub does not provide shell access.

Configure your git settings in your CSE account

In setting up GitHub, you want to make sure that you can connect properly and have easy access to additional information. In your CSE account, type the following four commands. Note that in the first two you should replace "YOUR NAME" and "YOUR EMAIL ADDRESS" with the appropriate information, though make sure to leave the quotes around it. Note: the email address you input should match the one GitHub has verified to ensure notifications go to the right place.

git config --global "YOUR NAME"
git config --global "YOUR EMAIL ADDRESS"
git config --global core.editor "nano"
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%C(yellow)%d %Cgreen%cr %Cblue%an%Creset %s' --date=relative --all"

The first two commands let git know your name and email (which is used to mark who made each commit). The next one sets the editor to nano. Git opens an editor when you need to compose a commit message. The last command makes a new git command named "lg", it is a much improved version of "log". You invoke it with "git lg".

Also, some of you may have python3 pointing at an incorrect version of python. If you run "which python3" it should return "/usr/bin/python3". If not, run:

echo 'set path = ( /usr/bin $path )'>>~/.login-personal

This should add the correct directory to the front of your path ensuring the correct python3 executable is used. You will need to logout and re-login to have the change take effect.

Continuous Integration

One easy way to confirm that the code the instructors will grade is the code you want graded is to use continuous integration. You can configure Travis-CI to run the tests of your code every time you push commits to GitHub. It can even email you the results of the tests. Here's how to set it up:

  1. Go to
  2. Ensure you are signed into
  3. In the upper right, click "Sign In with GitHub"
  4. Click "Authorize Application"
  5. Go back to

Setup local repository

You need to accept the invitation to join this class's GitHub organization, you can do so from the email sent by GitHub or go the organization's webpage (

Then, you should clone your individual repository onto the CSE machines. Go into the Home directory and type (making sure to replace STUDENT_USERNAME with your actual MSU Net ID):

git clone

Once you have all of the files in place, make sure you can change the names of many of the files and commit that change (this is mostly a test to make sure that we can see the changed files).

cd STUDENT_USERNAME-database/Project0

You should also add remote "instructor" for future projects scaffold and solutions.

git remote add instructor

Solve Project 0

Edit README.txt to have your name. Next commit your change with:

    git add README.txt
    git commit -m "My first commit"

You can see the change in the log with:

git lg

You should push your commits to GitHub now:

git push -u origin master

In the future, you only need to run git push to push.

Finished solving Project0 (edit/create README.txt and You can run the tests with:


Be sure to commit and push early and often.

Hence forth, you should also fetch and merge from the instructor remotes to get changes made to that repository (new projects, solutions, and bugfixes). I've pushed the first project Project1 to the instructor repo. Follow these commands to incorporate that code with your own.

git fetch instructor
git lg
git merge instructor/master -m "Merging with instructor"

You should now have a Project1 folder in your repository.

More Resources

In the sidebar, there is Helpful Links page that recommends resources on learning git. If this is your first time with the software, you must work though one of the tutorials before asking for help.