Phase 2 10 min windows macos linux

Clone a Repository

Get lab starter code from GitHub to your computer

The Assignment Workflow

Every assignment in this course follows the same pattern:

  1. I post a link on Canvas (a GitHub Classroom invitation).
  2. You click it and accept the assignment.
  3. GitHub creates a private repo with starter code, just for you.
  4. You clone that repo to your computer.
  5. You code, committing and pushing as you go.
  6. Automated tests run on each push — you can see results on GitHub.
  7. Your last push before the deadline is your submission.

Cloning is step 4. It copies the entire repo — code, history, and Git tracking — from GitHub to a folder on your machine.

Where to Put Your Repos

Before cloning anything, create a consistent place to store your course work:

mkdir -p ~/Documents/cscd210

All your repos will go inside this folder. One subfolder per assignment. Keep things organized from day one — it pays off.

  1. Go to your assignment repo on GitHub (e.g., https://github.com/cscd210-w26/lab01-yourname).
  2. Click the green “Code” button.
  3. Copy the HTTPS URL.
  4. Open VS Code.
  5. Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS).
  6. Type Git: Clone and select it.
  7. Paste the URL.
  8. When prompted for a location, navigate to ~/Documents/cscd210/ and click “Select as Repository Destination.”
  9. VS Code will ask if you want to open the cloned repo. Click “Open.”

You’re now working inside the project. You should see the starter files in the Explorer panel on the left.

Clone from the Terminal

If you prefer the command line:

cd ~/Documents/cscd210
git clone https://github.com/cscd210-w26/lab01-yourname.git
cd lab01-yourname

Then open it in VS Code:

code .

Verify the Clone Worked

Inside the cloned folder, run:

git status

You should see:

On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

This means you have a working Git repository connected to GitHub. If you see fatal: not a git repository, you’re in the wrong folder — cd into the cloned directory.

Also check that the starter files are there:

ls

You should see files like build.gradle.kts, src/, gradlew, etc. The exact files depend on the assignment.

Clone vs. Download ZIP

GitHub has a “Download ZIP” option. Don’t use it. Here’s why:

  git clone Download ZIP
Tracks changes Yes No
Can push back to GitHub Yes No
Can run git status, git log Yes No
Connected to your remote repo Yes No

A ZIP download is just a snapshot of the files. It has no Git history, no remote connection, and no way to submit your work. Always clone.

The Push Workflow (Preview)

After you’ve cloned and made changes, here’s how you submit:

git add .
git commit -m "Complete part 1"
git push

Or use VS Code’s Source Control panel (the branch icon in the left sidebar):

  1. Review changed files.
  2. Type a commit message.
  3. Click the checkmark to commit.
  4. Click the “…” menu and choose Push (or use the sync button).

You’ll practice this in your first assignment. For now, just know the pattern.

Common Errors

“Repository not found” or 403 error

  • You haven’t accepted the assignment yet. Go to Canvas, click the GitHub Classroom link, and accept.
  • You’re not signed into the right GitHub account. Check with gh auth status or sign in through VS Code.

“fatal: destination path already exists”

You already cloned this repo. The folder is already there. Just cd into it instead of cloning again. If you want a fresh copy, delete the folder first and re-clone.

Clone starts but hangs or fails

  • Check your internet connection.
  • If you’re on campus Wi-Fi and it’s slow, try again on a different network.
  • Make sure you’re using the HTTPS URL, not the SSH URL (unless you’ve specifically set up SSH keys).

“Please make sure you have the correct access rights”

Authentication issue. Open VS Code, run Cmd/Ctrl+Shift+P > GitHub: Sign In, and try cloning again.

Next Step

You can clone repos. Next, learn about Gradle, the build tool that compiles and tests your Java code.