Home CPSC 225

Assignment 4: Using Github


Due: November 11



To gain experience creating and using repositories on Github.

You should have completed week eleven before attempting to complete this assignment.



In this assignment, you will be following the steps of creating a repository on Github, as discussed in week 11. Github is widely used by software developers to keep track of software projects. In your studies here you can use it for individual and group class projects, but be sure to confirm this with your instructor! You can also use it for personal projects. Some potential employers will even ask if you have a Github account to see a selection of your work.

Because it is so useful, in CS coursework and beyond, this assignment will guide you through the process of using it.



  1. Begin by creating a Github account if you do not already have one. You can do this by following the steps here. Be sure to also create an SSH key and add the key to Github!
  2. Next, create a repository on Github called "assignment4". The steps for creating a centralized Github repository can be found here. Leave the description blank. The repository should be a public one. You should initialize the repository with a README, but don't need a .gitignore or a license. You also do not need to invite collaborators for this assignment, this project will be just you.
  3. Now, login to your VM and clone your repository. To do this, you can follow these steps. After completing this step, you should have a directory called "assignment4". In that directory should be a file called "README.md".
  4. Next you will modify the README.md file. Open it up with Vim, and you should see one line which says "# assignment4" on it. Add a second line which says "This is a test project".

    Then commit this change with the git commit command. For the commit message, enter "Added description". Then push the change with the git push command. If this worked well you should see a message something like the following:

    finlaysoni@myvm:~/assignment4$ git push
    Counting objects: 3, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 308 bytes | 308.00 KiB/s, done.
    Total 3 (delta 2), reused 0 (delta 0)
    remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
    To github.com:IanFinlayson/assignment4.git
       042879a..50f15fa  master -> master

    If you see a message asking to a username for https://github.com, then you need to clone the repository using SSH instead of HTTPS.

    If you see a message saying "ERROR: Permission denied...Please make sure you have the correct access rights and the repository exists." then the likely issue is that you have not setup your SSH keys on Github correctly.

  5. Next we will add a new file to the repository. Make a file called "hello.py" with the following contents:
    # just print hello world
    print("Hello World!")

    Add the file to the repository with git add. Then commit it with the message "Added a file", and push it the same way you did in step 4.

  6. Next, run the program in the Python interpreter like so:
    finlaysoni@myvm:~/assignment4$ python3
    Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
    [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import hello
    Hello World!

    This will create a folder called "__pycache__" which Python uses for temporary files. If we run the "git status" command here, it will tell us that this directory is not tracked. The proper way of handling this is to add it to the .gitignore file. This is explained here. Add the __pycache__ file to .gitignore, then commit and push the change to .gitignore (using the commit message "Added .gitignore").

    When you are done, git status should report "nothing to commit, working tree clean".



To submit this assignment, you will simply be turning in the URL of your repository on Github.

Open up a file called "repo.txt" and put in the URL of your repository on the first line. So for instance something like "https://github.com/GHusername/assignment4", with your actual Github username of course.

Then, turn this file in with:

submit username 4 repo.txt

Where username is your UMW netid.

This will transfer your submission to the server where it will be graded. It will print your grade to the screen and record your grade. You can submit the assignment as many times as you like. Your best grade will be used.

Copyright © 2022 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.