Clone a Repository
Get lab starter code from GitHub to your computer
The Assignment Workflow
Every assignment in this course follows the same pattern:
- I post a link on Canvas (a GitHub Classroom invitation).
- You click it and accept the assignment.
- GitHub creates a private repo with starter code, just for you.
- You clone that repo to your computer.
- You code, committing and pushing as you go.
- Automated tests run on each push — you can see results on GitHub.
- 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.
Clone Using VS Code (Recommended)
- Go to your assignment repo on GitHub (e.g.,
https://github.com/cscd210-w26/lab01-yourname). - Click the green “Code” button.
- Copy the HTTPS URL.
- Open VS Code.
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS). - Type
Git: Cloneand select it. - Paste the URL.
- When prompted for a location, navigate to
~/Documents/cscd210/and click “Select as Repository Destination.” - 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):
- Review changed files.
- Type a commit message.
- Click the checkmark to commit.
- 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 statusor 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.