Local Git Repository → GitHub → GitHub Pages Static Site (macOS)
0 — What This Does
Creates a local Git repository, links it to GitHub, publishes it as a static website using GitHub Pages, and exposes the site URL in the repository info.
1 — Tools You Must Have
-
Git
Open Terminal (Applications → Utilities → Terminal) and enter:
git –versionIf Git is not installed, macOS will prompt you to install Command Line Tools.
Click Install and wait. -
Visual Studio Code
https://code.visualstudio.com
Download the macOS version -
GitHub account
https://github.com
2 — GitHub Authentication
GitHub does not accept passwords for Git operations.
Create a Personal Access Token (PAT)
- On GitHub: Profile → Settings
- Developer settings → Personal access tokens → Tokens (classic)
- Generate new token
- Select scope: repo
- Generate token
- Copy and store the token securely
When Git asks for a password, paste the token.
NOTE: You may not be prompted if Git already has your credentials saved. This is normal. This step is something for first time users and it won’t hurt to know how to generate a token!
3 — Create the GitHub Repository
- Log in to GitHub
- Click New repository
- Enter repository name
- Do NOT check:
- Add a README
- Add .gitignore
- Add a license
- Click Create repository
- Copy the HTTPS repository URL (ends in .git)
4 — Create Local Project Folder and Open in VS Code
- Create or choose a folder on your computer
- Open Visual Studio Code
- File → Open Folder
- Select the folder
- View → Terminal
5 — Initialize Git and Connect to GitHub
In the terminal, enter:
git init
git remote add origin paste-repo-URL
git remote -v
Confirm that both fetch and push URLs appear (if you see an error here and don’t know why, the simplest fix is to delete the local folder and repeat steps 4–7. The GitHub repo does not need to be recreated.)
6 — Create a Basic Static Site
GitHub Pages requires an entry file.
-
In the project folder, create a file named: index.html
-
Add minimal content:
``` <!DOCTYPE html>
Hello, world
```
- Save the file.
7 — First Commit and Push (Using VS Code Source Control)
-
In VS Code, click Source Control
(the branching icon: three dots connected by lines) -
Under Changes, click Stage All
(the + icon), or stage individual files -
In the Message field, enter:
initial site -
Click Commit
-
Click Publish Branch
(or Sync Changes, if shown)
If prompted:
- Username: your GitHub username
- Password: paste your Personal Access Token (PAT)
If Publish Branch does not appear:
- Press Cmd+Shift+P
- Run: Git: Publish Branch
8 — Enable GitHub Pages
- Open the repository on GitHub
- Go to Settings
- Select Pages from the left sidebar
- Under Build and deployment:
- Source: Deploy from a branch
- Branch: main
- Folder: / (root)
- Click Save
When the Save button is no longer clickable, look to the left column for Pages and click that. What we’re looking for is the url of your site and in may take a few minutes to generate, so you’ll need to refresh tha page a couple times till it appears. Copy the URL of your live site. The Pages site will not appear until at least one successful push to main exists.
9 — Add the Pages URL to Repository Info
- Go to the repository main page
- Click the gear icon next to About
- Check Website
- Paste the GitHub Pages URL
Example: https://username.github.io/repository-name/ - Save
This makes the site link visible on the repository page.
10 — Verify the Site
- Open the Pages URL in a browser
- Confirm index.html loads
- If it does not:
- Wait 2 minutes
- Hard refresh (Cmd+Shift+R)
11 — Ongoing Workflow
Edit files in VS Code and save changes.
To publish updates:
- Open Source Control (the icon looks like a circuit diagram)
- Stage files (+)
- Enter a commit message
- Commit
- Sync Changes
Updates will appear on the site after a short delay.
12 — Pull Remote Updates (for collaborating with others or if you sync changes from different computers, etc.)
Either:
- Click Sync Changes
- Or in terminal:
git pull
13 — Safe Diagnostic Command
At any time, run:
git status
This command never changes files and explains Git’s current state.
14 — Making Changes
In VS Code, change the text in the index.html page between the <h1> tags to add an exclamation point.
The Source Control icon should show a number, click it.
In the Message field, write a short description of your change.
Below the Commit button, click the plus sign <+> by the word “Changes” (this “stages” the changes)
Click Commit, then Sync Changes.
If you check your repository, the index.html page should show your changes; they will take time to appear on your website, however.
Next we will add an extension called “Live Server” so that we don’t have to wait for the site to update to see our changes. We’ll also add extensions to help us with spell checking, HTML coding, and Markdown — but this is a good stopping point!