GitHub
GitHub hosts Git repositories online and adds collaboration: pull requests, issues, Actions and your public portfolio.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Oct 29, 2026
Related tutorials
Interview questions
Learning objectives#
- Connect a local repo to GitHub
- Push, pull and clone
- Authenticate with SSH keys
- Use issues and branch protection
Explanation#
A remote (usually named origin) is the GitHub copy of your repository. git push sends commits; git pull fetches and merges others’ commits.
Authenticate with SSH keys or the GitHub CLI (gh auth login) instead of passwords.
Issues track bugs and tasks; README.md is the front page of your project.
Branch protection rules can require pull requests, reviews and passing checks before merging to main.
Code example: Publish a project to GitHub#
ssh-keygen -t ed25519 -C "asha@example.com" # then add ~/.ssh/id_ed25519.pub in GitHub → Settings → SSH keys
git remote add origin git@github.com:asha/shop-api.git
git branch -M main
git push -u origin main
# Later, on another computer
git clone git@github.com:asha/shop-api.git
git pull # get the latest commits
To github.com:asha/shop-api.git * [new branch] main -> main branch 'main' set up to track 'origin/main'.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- An ed25519 SSH key authenticates you without passwords.
- git remote add connects the local repo to GitHub.
- push -u sets the upstream so later pushes are just git push.
- clone downloads the full repository elsewhere.
Real-world use case#
Students publish every project to GitHub with a good README; recruiters see real code and commit history.
Common mistakes#
Protect main and require pull requests.
Explain what the project does, how to run it and include screenshots.
Best practices#
- SSH or gh CLI authentication
- Protect main with required reviews and checks
- Write a helpful README
- Enable secret scanning and Dependabot
Remember this#
origin = the GitHub copy.
push sends, pull receives, clone copies.
Protect main.
Practice exercise#
Your task: Show which remotes your repository has.
Show solution
git remote -v
Mini quiz#
What does git push -u origin main do the first time?
Want more? Practise all DevOps MCQs · DevOps interview questions
My notes#
Saved in this browser.