Lesson 39 +30 XP

Project 4: Connect to GitHub

Project 4: Connect to GitHub

Push a local repository up to GitHub and practice the pull, push loop.

Step 1: Create a GitHub repository

  1. Sign in to github.com.
  2. Click the + icon, then New repository.
  3. Name it, for example my-blog.
  4. Leave it empty (no README).
  5. Click Create repository.

Step 2: Connect your local repo

Back in your terminal:

git remote add origin https://github.com/your-username/my-blog.git
git push -u origin main

Refresh GitHub and your files are there.

Step 3: Push new commits

Make a change, commit it, and push:

git add .
git commit -m "Add about page"
git push

The -u flag from before means plain git push now works.

Step 4: Pull changes

Make an edit on GitHub (use the web editor), then pull it down:

git pull

Step 5: Clone on another machine

git clone https://github.com/your-username/my-blog.git

TL;DR

  • Create an empty repo on GitHub.
  • Connect with git remote add origin URL.
  • Push with git push -u origin main.
  • Sync with git pull and git push.