How to Upload Site to GitHub- Step-by-Step Tutorial
How to Upload Your Site to GitHub: Step-by-Step Tutorial
GitHub Pages lets you host websites for free. No excuses. This guide covers both the GUI method and the command line approach so you can pick what works for you.
Here's what you'll get: clear steps, no fluff, and solutions to problems you'll actually hit.
What You Need Before Starting
- A GitHub account (free tier works fine)
- A website project ready to upload (HTML, CSS, JS files)
- Either GitHub Desktop installed or Git CLI on your computer
- Internet connection
That's it. No paid tools needed.
Two Methods: Pick Your Poison
You can upload via GitHub Desktop (easier for beginners) or the command line (faster once you know it). Here's how they compare:
| Method | Best For | Difficulty | Speed |
|---|---|---|---|
| GitHub Desktop | Beginners, one-time uploads | Low | Moderate |
| Git CLI | Developers, ongoing projects | Medium | Fast |
| GitHub Web UI | Quick single-file edits | Slow for multiple files |
Method 1: GitHub Desktop (Easiest Way)
This is the way to go if you want zero command-line headaches.
Step 1: Create a New Repository
Open GitHub Desktop. Click File → New Repository.
Fill in the details:
- Name: use something like "my-website" (lowercase, no spaces)
- Description: optional but helps you remember what it is
- Local path: where your website files live on your computer
Click Create Repository.
Step 2: Add Your Website Files
Copy your HTML, CSS, images, and other files into the folder you just selected as your local path.
Back in GitHub Desktop, you'll see your files listed under Changes. They're uncommitted right now.
Step 3: Commit Your Changes
In the bottom-left corner, there's a Summary field. Type something like "Initial upload" or "Added website files."
Click the Commit to main button. This saves your files locally.
Step 4: Publish to GitHub
Look for the Publish repository button in the top-right (or Push origin if you've done this before).
Make sure Keep this code private is unchecked if you want a public site. Check Organization only if you're uploading to an organization account.
Click Publish repository.
Step 5: Enable GitHub Pages
Go to your repository on github.com. Click Settings (the gear icon).
Scroll down to GitHub Pages. Under Source, click the dropdown and select main branch and / (root) folder.
Click Save.
Wait 1-2 minutes. Your site will be live at: username.github.io/repository-name
Method 2: Git Command Line
More powerful, but requires you know basic terminal commands.
Step 1: Install Git
Download Git from git-scm.com. Run the installer. Accept defaults unless you know what you're doing.
Step 2: Create Your Repository on GitHub
Go to github.com, click the + icon in the top-right, select New repository.
Name it something clear. Make it public if you want free hosting. Click Create repository.
Important: Don't check "Initialize this repository with a README" if you already have files to upload. It'll cause merge conflicts.
Step 3: Initialize Git in Your Project Folder
Open your terminal or command prompt. Navigate to your website folder:
cd path/to/your/website
Run these commands in order:
git init
git add .
git commit -m "Initial commit"
The git add . stages all your files. The commit saves them with a message.
Step 4: Connect and Push
GitHub gives you commands to run. They look something like this:
git remote add origin https://github.com/username/repo-name.git
git branch -M main
git push -u origin main
Enter your GitHub credentials when prompted. Done.
Step 5: Enable GitHub Pages
Same as Method 1: go to Settings → GitHub Pages → Source → main branch → Save.
Common Problems and Fixes
404 Error After Uploading
Your main file must be named index.html. GitHub Pages looks for this file by default. Rename your homepage if needed.
Changes Not Showing
GitHub Pages can take up to 5 minutes to update. Check your commit history to confirm your files actually pushed. Hard refresh your browser (Ctrl+Shift+R).
Repository Not Found Errors
Your repository name must match your GitHub username exactly for the default GitHub Pages URL to work. Custom domains fix this, but that's another tutorial.
Authentication Failures
Password auth for Git is dead. Use a Personal Access Token instead:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate new token with repo scope
- Use this token as your password when pushing
Custom Domains on GitHub Pages
Want your site at yourdomain.com instead of username.github.io?
Buy a domain from any registrar (Namecheap, GoDaddy, etc.). In your repository Settings → Pages:
- Enter your custom domain in the Custom domain field
- Check Enforce HTTPS after DNS propagates
Add these DNS records at your registrar:
- A records pointing to GitHub's IPs: 185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153
- CNAME record: www pointing to yourusername.github.io
DNS changes take up to 48 hours but usually propagate in under an hour.
Quick Reference: Commands to Remember
| Command | What It Does |
|---|---|
| git init | Creates a new Git repository |
| git add . | Stages all changed files |
| git commit -m "message" | Commits staged files with a note |
| git push | Uploads commits to GitHub |
| git status | Shows what's changed since last commit |
| git pull | Downloads changes from GitHub |
Which Method Should You Use?
Use GitHub Desktop if you're new to this, hate typing commands, or only upload occasionally.
Use the CLI if you're a developer, work on multiple projects, or want to automate deployments.
Both get you the same result. Pick whichever feels less painful.
Your site is live now. Commit changes and push whenever you update. GitHub Pages pulls automatically.