GitHub Basics
What is GitHub?
GitHub is where your code lives online. Think of it as a cloud backup for your project that also lets your instructors see your work, give feedback, and help you when you're stuck.
You write code on your computer (in Cursor). GitHub stores a copy of that code on the internet.
Key words
You only need to know a few terms:
- Repository (repo): A project folder on GitHub. It holds all of your project's files.
- Commit: A save point. When you commit, you're saying "here's what I changed and why."
- Push: Send your commits from your computer up to GitHub.
- Pull: Download the latest version from GitHub to your computer.
- Clone: Copy a repo from GitHub to your computer for the first time.
That's it. Everything else builds on these.
Files and folders (quick refresher)
If files and folders feel confusing, here's the short version:
- A file is a single document. Your code lives in files like
index.htmlorapp.py. - A folder (also called a directory) holds files and other folders. It's just a container.
- Your project is a folder that contains all the files for what you're building.
- When you open a project in Cursor, you're opening a folder. The file explorer on the left shows you everything inside it.
On GitHub, a repository is just a folder that GitHub keeps track of.
How GitHub works with Cursor
Here's the basic loop you'll follow every class:
Open your project in Cursor
↓
Write code
↓
Save your files (Cmd+S / Ctrl+S)
↓
Commit (describe what you changed)
↓
Push (send it to GitHub)
Step by step
1. Open your project
If you've already cloned your repo, just open the folder in Cursor (File > Open Folder).
If this is your first time, you'll clone it:
- Go to your repo on GitHub and click the green "Code" button
- Copy the URL
- In Cursor, open the terminal (View > Terminal) and run:
git clone <paste-the-url-here>
Then open the new folder in Cursor.
2. Make changes
Edit files, add new ones, delete what you don't need. Work normally.
3. Save your files
This sounds obvious, but it's the most common mistake. If you don't save, your changes won't show up when you commit. Use Cmd+S (Mac) or Ctrl+S (Windows/Chromebook) often.
4. Commit your changes
In Cursor, click the Source Control icon in the left sidebar (it looks like a branch/fork). You'll see a list of files you've changed.
- Click the
+next to each file to stage it (this tells Git "include this file in my commit") - Type a short message describing what you did (e.g. "added homepage layout")
- Click the checkmark to commit
Or, from the terminal:
git add .
git commit -m "added homepage layout"
5. Push to GitHub
Click the "Sync Changes" button in Cursor, or from the terminal:
git push
Your code is now on GitHub. Your instructors can see it.
Common problems
| Problem | What's happening | Fix |
|---|---|---|
| "I committed but my instructor can't see it" | You committed but didn't push | Run git push |
| "It says I have 'merge conflicts'" | You and someone else changed the same file | Ask an instructor for help -- this is normal |
| "Nothing shows up in Source Control" | You haven't saved your files | Save with Cmd+S / Ctrl+S |
| "It says 'not a git repository'" | You opened the wrong folder | Make sure you opened the cloned repo folder, not a parent or child folder |
| "I don't know what to write in the commit message" | Just describe what you did | Something like "worked on login page" or "fixed broken link" is fine |
Ask your agent for help with Git
You don't have to memorize any of this. If you're in Cursor (or Codespaces), you can ask the AI agent to walk you through it. Here are some prompts you can copy and paste:
Saving your work:
Help me commit and push my changes to GitHub. Walk me through it step by step.
Something's not working:
I made changes but nothing shows up in Source Control. What did I do wrong?
Getting the latest version:
How do I pull the latest version of my project from GitHub?
Merge conflicts:
I'm getting a merge conflict. Help me understand what happened and how to fix it.
Undoing a mistake:
I think I broke something. How do I undo my last change?
General confusion:
I don't understand what Git is doing right now. Can you look at my repo and explain what state it's in?
You can also just describe your problem in plain language. The agent knows about Git and will give you the steps.
Tips
- Commit early and often. Small commits are easier to understand than one giant commit at the end of class.
- Your commit messages don't need to be fancy. "added navbar" is better than no message.
- If something goes wrong with Git, don't panic. Ask an instructor or your agent. Git mistakes are almost always fixable.
- Push before you leave class every week. That way your work is safe even if your computer has problems.