In our subsequent labs, we will be using Google Colab to write and run Python code, and we will use GitHub for version control. In this write-up, we will walk you through how to do the following:
Link your Google Colab account with your GitHub account
Create a new GitHub repository
Create a new Google Colab notebook
Save a Google Colab notebook to an existing GitHub repository
You will likely only need to do #1 once, #2 and #3 once at the beginning of every lab, and #4 multiple times per lab.
Unrelated to this tutorial, but one benefit of Google Colab notebooks compared to just writing basic Python code is that, in addition to code comments, we can use Markdown to write formatted text within our notebook!
Before doing anything, you need to first create a Google account (to be able to use Google Colab) and a GitHub account. Every single SPIS student should only have to do this once ever.
Your Colab files will be stored on your Google Drive. So use the appropriate Google account you want to store your files under. This can be your UCSD account or personal one, it doesn't matter; if you are unsure, we recommend you use your UCSD account.
Go to Google Colab: https://colab.research.google.com/
If you're already signed in (e.g. if you already have a Google account and are signed into it), you're good to go! You can check which google account you are currently using by clicking on the icon in the top right corner.
If you're not already signed in, click the "Sign In" button at the top-right
If you already have a Google account, sign into it
If you don't already have a Google account, click the "Create account" button towards the bottom-left, and follow the on-screen instructions to create one.
Go to GitHub: https://github.com/
If you're already signed in (e.g. if you already have a GitHub account and are signed into it), you're good to go!
If you're not already signed in, but you already have a GitHub account, click the "Sign in" button at the top-right and sign into it
If you're not already signed in and don't already have a GitHub account, click the "Sign up" button at the top-right, and follow the on-screen instructions to create one. However, if you did Lab 0, you should already have a GitHub account.
Before you can synchronize your Google Colab notebooks with GitHub, you need to link your Google Colab account with your GitHub account. Every single SPIS student should only have to do this once ever.
Go to Google Colab: https://colab.research.google.com/
Click "Cancel" because you don't want to create a new notebook right now (you just want to link it to GitHub)
Click the gear icon in the top-right (to the right of "Comment" and "Share")
Click "GitHub" from the Settings menu that pops up
Click "Authorize with GitHub"
Click the green "Authorize googlecolab" button at the bottom right (it may ask you for your GitHub password again) and click "Save".
If you don't see an "Authorize googlecolab" button, you may need to do Step 7 (the bullet below this) first
Back in the "GitHub" menu in the "Settings" popup, check the "Access private repositories and organizations" box (and authorize it again if it asks)
Before you start any given lab, you will need to create a GitHub repository in which you will store your lab work. Every SPIS Student Pair (not individual student) should only have to do this once at the beginning of each lab.
Go to the SPIS 2023 GitHub organization: https://github.com/ucsd-cse-spis-2023
Go to the "Repositories" tab in the SPIS 2023 GitHub organization
Direct link for convenience: https://github.com/orgs/ucsd-cse-spis-2023/repositories
Click "New Repository"
Direct link for convenience: https://github.com/organizations/ucsd-cse-spis-2023/repositories/new
In the "Repository name" text box, enter spis23-labXX-Name1-Name2, where:
labXX is the lab name (as a 2 digit number), e.g., lab01, lab02, etc.
Name1 is the first pair partner’s preferred first name
Name2 is the second pair partner’s preferred first name
Be sure that "Private" is checked (not "Public")
Check the "Add a README file" box
Click the "Create repository" box at the bottom-right
Go to the new GitHub repository you just created
Click the "Settings" button at the far right of the menu bar at the top of the repository
Under "Access", click "Collaborators"
Click the "Add people" button
Type your Pair Partner's GitHub username into the search box
Click on your Pair Partner's GitHub account once it's found by the search box
Click the "Add XX to this repository" button (where XX is your Pair Partner's GitHub account)
You and your Pair Partner will both be using this single GitHub repository to store your lab code.
Before you start any given lab, you will need to create a Google Colab notebook in which you will write your code. Every SPIS Student Pair (not individual student) should only have to do this once at the beginning of each lab.
Go to Google Colab: https://colab.research.google.com/
Click "New notebook" at the bottom-right of the pop-up window, or (if you don't have the pop-up window anymore) to under "File" (top-left) and click "New notebook".
Name the notebook spis23-labXX-Name1-Name2.ipynb via the filename text box in the top-left (i.e., overwrite the default name that likely starts with "Untitled ...").
labXX, Name1, and Name2 are the same as described in "Part 2: Create a new GitHub repository"
You and your Pair Partner will both be using this single Google Colab notebook to write and run your lab code.
As you work on a lab, you will want to save your Google Colab notebook to your GitHub repository to save your progress on the lab. Every SPIS Student Pair (not individual student) should do this frequently throughout the lab.
In your Google Colab notebook, click "File" in the top-left, then click "Save a copy in GitHub" (NOT "Save a copy in GitHub Gist")
Once the "Copy to GitHub" popup loads, click on the "Repository" dropdown and pick your spis23-labXX-Name1-Name2 repository
labXX, Name1, and Name2 are the same as described in "Part 2: Create a new GitHub repository"
If you want, update the contents of the "Commit message" text box to some descriptive message (briefly) explaining what updates you've made since your last save
Click the "OK" button at the bottom-right to save your Google Colab notebook to your GitHub repository
Every time you make significant progress in a lab, follow these steps to save your work.