Before You Start

What you need

Lab computers on campus already have Git installed, so you can skip straight to Step 1 there. Everything on this page assumes VS Code is already installed — see IDEs & Code Editors if it isn't yet.

The Big Picture

What you do once, and what repeats every lab

The most common point of confusion: which of these steps you only ever do one time on a given computer, and which ones start over for every single lab. Each lab becomes its own separate GitHub repository, so most of this page repeats.

Once per computer, ever
  • Install Git (skip on lab computers)
  • Create your GitHub account
  • Set your Git name and email (Step 3 below)
  • Sign in to GitHub inside VS Code (happens automatically the first time you publish)
Every single lab
  • A brand new OneDrive folder
  • Open that folder in VS Code
  • Add this lab's file(s) to it
  • Initialize, commit, publish, copy the URL, submit to Canvas
Step 1

Create a folder on OneDrive

Every lab gets its own fresh folder. Don't reuse a folder from a previous lab, and don't put a new lab's files inside an old lab's folder.

  1. Open File Explorer (Windows) or Finder (Mac) and click OneDrive in the left-hand pane.
  2. Right-click an empty area inside OneDrive and choose New → Folder.
  3. Name the folder after this lab — for example, Lab 7. Use whatever name your instructor asks for; it's fine if it has a space in it.

Using OneDrive, not just any folder on your hard drive, means your files are backed up automatically and available if you switch to a different lab computer.

Step 2

Open the folder in VS Code

  1. Open VS Code and choose File → Open Folder…
  2. Browse into OneDrive, select the folder you just created, and click Select Folder (Windows) or Open (Mac).
  3. If VS Code asks "Do you trust the authors of the files in this folder?", click Yes, I trust the authors. You created this folder yourself, so it's always safe to say yes here.
Step 3 · One Time Per Computer

Set up your Git name and email

Skip this step entirely if you've already done it on this computer for an earlier lab. If you're not sure, it's harmless to run it again.

  1. Choose Terminal → New Terminal from the VS Code menu.
  2. Type the following two commands, pressing Enter after each one. Replace the name and email with the ones on your own GitHub account.
git config --global user.name "Your Name" git config --global user.email "[email protected]"

This is different from signing in to GitHub, which happens later in Step 6. Want to know exactly what this command does? See the core Git commands, explained.

Step 4

Add this lab's files to the folder

This step looks the same no matter what kind of file the lab uses, a Jupyter notebook, a .py script, or anything else your instructor hands out.

  1. Download the starter file(s) for this lab from Canvas, if there are any.
  2. If your instructor asks you to rename the file, usually by adding your name (for example, Lab7_JaneDoe.ipynb), do that now.
  3. Move or copy the file into the folder you opened in Step 2. It will appear automatically in VS Code's Explorer pane on the left.
  4. Open the file in VS Code and complete the lab. Save your work as you go (Ctrl+S on Windows, Cmd+S on Mac).

Saving the file and submitting the lab are not the same thing. Ctrl+S only saves to your OneDrive folder. Nothing is on GitHub, and nothing is submitted, until you complete Steps 5 through 7 below.

Step 5

Commit your work

  1. Click the Source Control icon on the left side of the VS Code window — it looks like three dots connected by branching lines.
  2. Click Initialize Repository. (You'll only see this button the first time for each new folder — this is what turns a plain folder into a Git project.)
  3. Type a short message, such as Initial commit, into the message box at the top of the panel.
  4. Click the checkmark icon (or press Ctrl+Enter) to commit.
  5. If VS Code asks whether to stage all your changes and commit them directly, click Yes.

This saves a snapshot on your own computer. It still hasn't gone anywhere — that's the next step.

Step 6

Publish to GitHub

  1. Click Publish Branch in the Source Control panel.
  2. The first time you do this on a computer, VS Code asks you to sign in to GitHub. Click Allow, then finish signing in through the browser tab that opens, then switch back to VS Code.
  3. When asked how to publish, choose Publish to GitHub public repository. It needs to be public so your instructor can open and grade it.

Already signed in from a previous lab? VS Code remembers you, and this step just asks Public or Private before publishing.

Step 7

Copy your GitHub URL and submit it

  1. When publishing finishes, click Open on GitHub in the pop-up that appears in the bottom right corner of VS Code. If you miss the pop-up, go to github.com, sign in, and open the repository from your profile.
  2. Double check that your lab's file actually shows up in the repository's file list on the GitHub page.
  3. Copy the full URL from your browser's address bar. It will look something like https://github.com/your-username/Lab-7.
  4. Paste that URL into the Canvas submission box for this lab.
Related

More to explore