Lesson 5.2: Setting Up Git, GitHub, and Creating the Project
Lesson Quick-Jump (10 Sections)
1. What Are We Learning?
In this lesson, you will learn how to:
- Initialize Git in your project folder and connect it to GitHub.
- Create your initial starter project cleanly matching your Phase 4 architecture.
- Copy your planning docs (
docs/) into the repository. - Verify the starter app runs locally before adding any custom features.
2. Why Does It Matter?
Starting with Git and a working "Hello World" skeleton gives you a safe save point. Before the AI writes complex feature code, you know:
- Your baseline project boots cleanly with zero errors.
- Your work is safely backed up on GitHub.
- If an AI edit breaks everything tomorrow, you can immediately inspect what changed or revert back to your clean baseline.
3. Simple Explanation for a Complete Beginner
- Git is like a time machine / save-game system living inside your project folder. Every time you make a commit, Git records an exact snapshot you can return to later.
- GitHub is an online vault where you push (upload) those snapshots so you don't lose your work if your laptop breaks, and so you can inspect diffs cleanly in a browser.
Creating a project properly follows a simple ritual:
- Scaffold the minimal starter project (empty working skeleton).
- Add
.gitignore,.env.example, and yourdocs/folder (PRD, design direction, architecture doc, development plan). - Run the app locally to confirm it starts cleanly.
- Make your initial commit and push it to GitHub.
4. Practical Example
Suppose you are starting your habit-tracker repository:
- Create a new empty repository named
habit-trackeron GitHub (keep it Private or Public—either works, though Private is safer while learning if unsure). - On your computer, inside your project folder:
- Initialize the project with your stack's starter command (or ask the AI to inspect the empty folder and propose the exact starter command).
- Confirm
.gitignoreincludes.envBEFORE runninggit add. - Start the local server (e.g., opening
http://localhost:3000in your browser) and confirm the starter page loads cleanly. - Commit and push:
git initgit status # Check which files are about to be staged!git add .git commit -m "chore: initialize project skeleton and planning docs"git branch -M maingit remote add origin <your-github-repo-url>git push -u origin main
Notice git status right before git add .! That single check prevents accidentally uploading .env or stray huge folders.
5. Step-by-Step Instructions
- Create a GitHub account (if you don't have one) and configure your Git name/email locally:
git config --global user.name "Your Name"git config --global user.email "you@example.com"
- Create a new empty repository on GitHub (do not add conflicting starter files if you are creating the project locally first, or clone the empty/README repo to your computer).
- Scaffold your minimal starter project using your chosen stack's official starter tool (ask AI for the exact command for your stack, and check it first).
- Add your planning documents into
docs/(prd.md,development-plan.md,design-direction.md,architecture.md). - Verify
.gitignoreand.env.exampleare in place. - Start the app locally and open the local URL in your browser to confirm it runs with zero errors.
- Run
git status, verify no secrets or giant dependency folders appear, then make your first commit and push to GitHub.
Stuck on GitHub's screens? Don't waste hours on long Git courses—watch one quick 5–10 minute YouTube walkthrough on creating your first GitHub repo, or screenshot whatever screen you see in Chrome and use Prompt 6: Break Down a Confusing Screen so AI guides you button by button.
6. Ready-to-Use AI Prompt
Context:
I am ready to initialize my project locally and connect it to GitHub.
- Chosen tech stack: [state your stack from Phase 4]
- Agreed folder structure: [paste your folder tree from docs/architecture.md]
- Current folder contents: [empty folder / existing files]
Objective:
Guide me step-by-step to scaffold the minimal starter project so it matches my agreed structure and runs locally on localhost.
Boundaries:
- Do NOT implement any app features yet—only the minimal runnable starter skeleton.
- Do NOT install unnecessary packages or UI libraries we haven't agreed on.
- Inspect the directory first (if using an IDE/terminal agent) before creating or editing files.
- Ensure `.gitignore` protects `.env` and dependency directories before any Git commit.
Expected Output:
1. Exact commands or file changes needed for the minimal starter skeleton.
2. How to run the app locally and what I should see in my browser/terminal to prove it works.
3. Exact `git status` check to run before committing.
7. What to Expect from the AI Agent
| Good Response | Warning Sign |
|---|---|
The agent scaffolds a clean, minimal starter app, configures .gitignore, explains how to start the local dev server, and stops before building features. | The agent generates 40 files, installs 15 extra packages, or scaffolds mock dashboard screens you didn't ask for. Stop and say: "Keep only the minimal runnable starter matching docs/architecture.md." |
8. What You Must Personally Verify
- Run
git statusbefore everygit add .: Make sure.env,node_modules/,.venv/, or personal files are NOT listed. - Confirm the app actually runs locally: Open the
localhostURL yourself in a browser and check the terminal for red error messages. - Check GitHub in your browser: After
git push, refresh your GitHub repository page to verify yourdocs/and starter files arrived safely—and double-check no secrets were uploaded.
9. Common Mistakes
- Forgetting
.gitignoreuntil after pushing: Once a secret is pushed to a public GitHub repo, deleting it in a later commit does not remove it from Git history—you must revoke/rotate the secret key immediately. Always set up.gitignorefirst. - Modifying files before verifying the starter runs: If you start adding features before confirming the baseline boots, you won't know whether an error came from your setup or your new feature.
- Never making an initial commit: Always commit your clean baseline before Phase 6 implementation begins.
10. Small Practical Exercise
- Create your project repository on GitHub and locally initialize your starter app with
docs/inside it. - Start the local development server and open it in your browser.
- Run
git status, verify no.envor dependency folders are staged, make your initial commit, push tomain, and verify the files appear on GitHub.
Completed the exercise? Track your progress
Check off this lesson in PROGRESS-CHECKLIST.md once you have verified every step in Section 8.