What is it?
A remote is a version of your repository hosted on a server. You push local commits to share them and pull to get others changes.
Why does it matter?
Remote repositories enable collaboration. Without them Git history only exists on your machine. GitHub is the shared source of truth for the whole team.
Learn remotes — clone, push, pull, fetch, and working with GitHub repositories.
Real-World Use Cases
- 🌐 Open source - Fork a repository, clone locally, make changes, push, open a Pull Request.
- 🚀 Deployment - CI/CD triggers on git push — automatic deployment without manual file transfers.
- 💾 Backup - Remote is an off-site backup — if your laptop dies, code is safe on GitHub.
- 👥 Code review - Push a branch and open a Pull Request for teammates to review.
Clone, Push, Pull
git clone https://github.com/user/repo.git
git remote add origin https://github.com/user/repo.git
git push -u origin main # -u sets upstream tracking
git pull # fetch + merge
Fetch vs Pull
git fetch origin # download changes, do NOT merge
git log HEAD..origin/main # see what changed
git merge origin/main # apply fetched changes
# git pull = git fetch + git merge
Multiple Remotes
git remote add upstream https://github.com/original/repo.git
git fetch upstream
git merge upstream/main # sync with original
git push origin main # push to your fork
Q: What is the difference between git fetch and git pull?
git fetch downloads changes from remote but does not touch your working files. git pull does git fetch then merges immediately. Use git fetch to review remote changes before applying. Use git pull when you trust the remote.
Comments (0)
No comments yet. Be the first!
Leave a Comment