Collaboration & GitHub · 8 min read · Beginner
Remotes, Push, Fetch & Pull
Sync your local repository with GitHub using origin, git push, git fetch, and git pull.
What you'll learn
- Connect a local repository to a remote named origin
- Understand the difference between git fetch and git pull
- Publish local branches safely with git push -u origin
A remote is a hosted copy of your repository (such as on GitHub or GitLab). By convention, your primary remote is named origin.
Fetch vs. Pull
git fetch origindownloads new commits and branches from GitHub without touching your working files. It is always safe to run.git pull origin mainrunsgit fetchand immediately merges (or rebases) remote changes into your current branch.git push -u origin feat/cardsuploads your local branch and sets up upstream tracking so future pushes only needgit push.
Fill-in-the-Blank Exercise
Sync with Origin
Download remote changes without merging, then publish a new branch with upstream tracking.
git origin
git -u origin feat-profileTry It Yourself (Interactive Git Terminal)
GitPrepare Commits for Remote Push
main
(main) $ git status
On branch main Untracked files: index.html, styles.css
Check Your Understanding
Score: 0 / 1
1. What does git fetch do compared to git pull?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.