Github for CS 340

git is the industry standard for collaborative code management. GitHub is the most popular server for attaching git projects to. Among git and GitHub’s many collaboration features (which we won’t use this semester) are several that will assist us in delivering and grading MPs.

The University of Illinois has an enterprise license to github.com and has enabled some security features which will make connecting to it more secure but also more involved than other GitHub sites.

1 Creating a GitHub Account

To log into GitHub, you will use your own personal GitHub account (not your Illinois NetID1 Technically you could use the same ID for GitHub and UIUC, but we expect most of you will not do that, possibly not even be allowed to do that by GitHub if someone else has that ID.). You will be privately associating your NetID with your GitHub account to be invited into the @cs340-illinois course organization.

If you do not have a GitHub account, you need to create a free GitHub account. Most people use their github.com as part of their professional identity, so choosing a professional username is encouraged (ex: tychonievich is Luther’s username, not dy$t0pia).

2 Creating Your Private Course Repository

In CS 340, all of your work will be submitted in your personal, private repository in @cs340-illinois on GitHub. We have developed a GitHub Repository Creator that will create a private repository for you in @cs340-illinois and set it up with the permissions so that course staff can also access you work.

3 Creating a Local Clone of Your CS 340 Repository

The git workflow is designed around working on a local clone of your repository that you regularly synchronize with your GitHub repository.

  1. On a terminal, navigate to your CS 340 directory (cs340):

    cd cs340
  2. Clone a local copy of your git repository with the following command (making sure to replace YOUR-GIT-REPO-URL with the URL from the "Course Repository Tool" above):

    git clone <YOUR-GIT-REPO-URL> <NETID>
    # Ex with PAT: git clone https://github.com/cs340-illinois/sp24_cs340_luthert luthert
    # Ex with SSH: git clone git@github.com:cs340-illinois/sp24_cs340_luthert.git luthert
    • ⚠️ You may get errors running this command and will need to set up your access to your GitHub.
    • git error messages are very good! Often the error message will contain a URL where you github provides you the next steps (ex: generating a token, adding OAuth permissions, etc). This command must be successful before you can continue.
    • Github is changing how some parts of their system work; we recommend avoiding anything marked beta
  3. Once you have a clone, navigate into your git directory by going into your NetID-named folder:

    cd <NETID>
  4. Connect the release repository, which is where initial code will be provided for you as part of CS 340:

    # if you used a personal access token:
    git remote add release https://github.com/cs340-illinois/sp24_cs340_.release
    # if you used an SSH key:
    git remote add release git@github.com:cs340-illinois/sp24_cs340_.release.git
    • If you get ANY OUTPUT AT ALL, it was NOT successful. (No output means no error! :))
    • git error messages are very good! Carefully and completely read the error message to help you out.
    • If you are not sure, you can run it again and it will say that "the remote already exists".
  5. Finally, let git know your student identity (replacing your name and e-mail):

    git config user.name "Your Name"
    git config user.email "netid@illinois.edu"

4 Avoid re-entering access tokens

You likely created a personal access token (PAT) to access the repositry. This is tedious to re-enter every time you work with a repository.

You can bypass this entry by storing the PAT in your project’s files. Inside the project directory is a file called .git/config which tells git various details about the repository. After running the above steps, you likely see two lines that contain https://github.com/…. You can edit these to instead say https://username:PAT@github.com/…, using your github username and PAT, and it should then operate without asking for additional logins.

Editing .git/config like this lets anyone on your computer impersonate you on GitHub ⚠ and should only be done if you’re working on a computer you own and keep secure from other users.

There is also a process that uses an SSH key instead of a personal access token