Introduction to GitHub
From here on, modules include walkthroughs that require a real GitHub account. Create a free account at github.com if you don't have one. The simulator still lets you practice the commands.
What is a Remote?
So far your git history lives only on your computer. A remote is a copy of your repository hosted elsewhere — typically GitHub. It serves as:
- A backup of your work
- A way to share code with teammates
- The source of truth for the team
Step 1: Create a Repo on GitHub
-
1Go to github.com and click the + icon → New repository
-
2Give it a name, leave it Public, and do not initialise with a README (you'll push your existing code)
-
3Click Create repository — GitHub shows you the commands to run next
Step 2: Connect Your Local Repo
Link your local repo to GitHub with git remote add:
git remote add origin https://github.com/your-username/your-repo.git
Verify it worked:
git remote -v
Step 3: Push Your Code
git push -u origin main
The -u flag sets the upstream tracking, so future pushes can just be git push.
Pulling Changes
If someone else (or you on another computer) has pushed new commits, get them with:
git pull
This is shorthand for git fetch (download) + git merge (integrate).
Local Repo
→ push →
GitHub
← pull ←
Local Repo
Authentication: GitHub no longer accepts passwords. Use a Personal Access Token (PAT) or SSH key. In GitHub → Settings → Developer settings → Personal access tokens → Generate new token. Paste it as your password when git prompts you.
Simulator Challenges
Add a remote:
git remote add origin https://github.com/user/repo.git
Verify it:
git remote -v
Push to GitHub (simulated):
git push origin main
student@git-mastery: ~/my-project (main)