Git on your laptop is only half the story. Remotes are copies of your repository hosted online — GitHub being the most popular. Remotes give you backup, collaboration, and a portfolio of your work.
Git vs GitHub (Again)
- Git — the tool, runs locally, tracks history.
- GitHub — a website that hosts Git repos, adds pull requests, issues, and social features.
You need a free account at github.com for this lesson.
Create a Repository on GitHub
- Log in to GitHub.
- Click + → New repository.
- Name it (e.g.
my-git-blog). - Leave it empty — no README, no
.gitignore(you already have those locally). - Click Create repository.
GitHub shows setup instructions. You want the "push an existing repository" section.
Connect Your Local Repo
In your project folder:
git remote add origin https://github.com/YOUR-USERNAME/my-git-blog.git
origin is the conventional name for your primary remote. You only set this up once per project.
Verify:
git remote -v
origin https://github.com/YOUR-USERNAME/my-git-blog.git (fetch)
origin https://github.com/YOUR-USERNAME/my-git-blog.git (push)
Push Your Commits
Upload your local history to GitHub:
git push -u origin main
The first time, -u links your local main to origin/main so future pushes are just git push.
GitHub may ask you to log in. Follow the browser prompt or use a personal access token as your password (GitHub no longer accepts account passwords for Git over HTTPS).
Refresh your repo page on GitHub — your files and commit history should appear.
Daily Push Workflow
After making local commits:
git status
git push
That's it. Your remote stays in sync with your local main.
Pull Changes Down
If you edit on another computer, or a teammate pushes changes, update your local copy:
git pull
git pull fetches remote changes and merges them into your current branch. Run it before starting work if others might have pushed.
Clone Someone Else's Repo
To copy a repo you don't own (or your own from a new machine):
git clone https://github.com/YOUR-USERNAME/my-git-blog.git
cd my-git-blog
clone downloads the entire history and sets up origin automatically. You can start working immediately.
SSH vs HTTPS
This lesson uses HTTPS URLs (https://github.com/...). They work everywhere and only need your GitHub login.
SSH URLs (git@github.com:...) use key-based auth — no password prompts once set up. Many developers prefer SSH long-term. GitHub's docs walk through generating an SSH key.
Either works. Pick one and stick with it for a given repo.
Pull Requests
On GitHub, you don't merge feature branches directly on the website during normal team flow. Instead:
- Push your branch:
git push -u origin dark-mode - On GitHub, click Compare & pull request
- Describe your changes
- A teammate (or you, reviewing your own work) approves and clicks Merge
Pull requests are where code review happens. Even solo, they're useful — you see a clean diff of everything before it hits main.
Quick Reference
| Command | What it does |
|---|---|
git remote add origin URL |
Link local repo to GitHub |
git push |
Upload commits to remote |
git pull |
Download and merge remote changes |
git clone URL |
Copy a remote repo to your machine |
Your code now lives in two places: your computer and GitHub. That's real-world Git — local work, remote backup, branches for features, and pull requests for review.