Skip to main content
Reading progress: 0%

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?​

info

Starting with Git and a working "Hello World" skeleton gives you a safe save point. Before the AI writes complex feature code, you know:

  1. Your baseline project boots cleanly with zero errors.
  2. Your work is safely backed up on GitHub.
  3. 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:

  1. Scaffold the minimal starter project (empty working skeleton).
  2. Add .gitignore, .env.example, and your docs/ folder (PRD, design direction, architecture doc, development plan).
  3. Run the app locally to confirm it starts cleanly.
  4. Make your initial commit and push it to GitHub.

4. Practical Example​

Suppose you are starting your habit-tracker repository:

  1. Create a new empty repository named habit-tracker on GitHub (keep it Private or Public—either works, though Private is safer while learning if unsure).
  2. 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 .gitignore includes .env BEFORE running git add.
    • Start the local server (e.g., opening http://localhost:3000 in your browser) and confirm the starter page loads cleanly.
    • Commit and push:
      git init
      git status # Check which files are about to be staged!
      git add .
      git commit -m "chore: initialize project skeleton and planning docs"
      git branch -M main
      git 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​

  1. 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"
  2. 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).
  3. 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).
  4. Add your planning documents into docs/ (prd.md, development-plan.md, design-direction.md, architecture.md).
  5. Verify .gitignore and .env.example are in place.
  6. Start the app locally and open the local URL in your browser to confirm it runs with zero errors.
  7. Run git status, verify no secrets or giant dependency folders appear, then make your first commit and push to GitHub.
tip

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 ResponseWarning 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 status before every git add .: Make sure .env, node_modules/, .venv/, or personal files are NOT listed.
  • Confirm the app actually runs locally: Open the localhost URL 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 your docs/ and starter files arrived safely—and double-check no secrets were uploaded.

9. Common Mistakes​

  1. Forgetting .gitignore until 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 .gitignore first.
  2. 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.
  3. Never making an initial commit: Always commit your clean baseline before Phase 6 implementation begins.

10. Small Practical Exercise​

  1. Create your project repository on GitHub and locally initialize your starter app with docs/ inside it.
  2. Start the local development server and open it in your browser.
  3. Run git status, verify no .env or dependency folders are staged, make your initial commit, push to main, 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.