Skip to content
Guest
Learn Git · Course Syllabus Show lessons
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 origin downloads new commits and branches from GitHub without touching your working files. It is always safe to run.
  • git pull origin main runs git fetch and immediately merges (or rebases) remote changes into your current branch.
  • git push -u origin feat/cards uploads your local branch and sets up upstream tracking so future pushes only need git 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-profile

Try 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.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind