Loading lessons...
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
- Sign in to github.com.
- Click the + icon, then New repository.
- Name it, for example
my-blog. - Leave it empty (no README).
- 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 pullandgit push.