GitHub Repos
Create, fork, and navigate repositories on GitHub
Skills taught: github.repos, github.fork, github.stars
Creating a repository
# Via GitHub CLI (recommended)
gh repo create my-project --public
gh repo create my-project --private
# Then push an existing local repo:
git remote add origin https://github.com/yourname/my-project.git
git push -u origin main
# Or clone right after creating:
gh repo create my-project --public --clone
cd my-project
Forking — contributing to open source
Forking copies a repo to your GitHub account so you can make changes. You then open a Pull Request to propose your changes to the original repo.
# 1. Fork on GitHub (click the Fork button)
# 2. Clone YOUR fork (not the original)
git clone https://github.com/YOUR-USERNAME/repo.git
cd repo
# 3. Add the original as 'upstream' remote
git remote add upstream https://github.com/ORIGINAL-OWNER/repo.git
git remote -v
# origin https://github.com/YOUR-USERNAME/repo.git (your fork)
# upstream https://github.com/ORIGINAL-OWNER/repo.git (original)
# 4. Create a branch, make changes, push to YOUR fork
git switch -c fix/typo-in-readme
# ... make changes ...
git push origin fix/typo-in-readme
# 5. Open PR on GitHub from your fork to the original
# 6. Keep your fork in sync with upstream
git fetch upstream
git switch main
git merge upstream/main
git push
Frequently Asked Questions
What is the difference between a fork and a clone?
A fork happens on GitHub's servers — it creates a copy under your account. A clone happens on your machine — it downloads a repo locally. When contributing to open-source, you typically fork first, then clone your fork.
How do I install the GitHub CLI?
macOS: brew install gh. Windows: winget install --id GitHub.cli. Ubuntu: sudo apt install gh. After installing, run gh auth login to authenticate with your GitHub account.