Tour of Git
Working with Remotes / Lesson 4.5

git pull — Getting Updates

The git pull command downloads changes from a remote and merges them into your current branch. It's essentially git fetch + git merge in one step.

Basic Usage

git pull origin main

What Pull Does

  1. Fetch: Download new commits from the remote
  2. Merge: Integrate the remote changes into your local branch
Before pull:
  local:   A --- B --- C  (main)
  remote:  A --- B --- D  (origin/main)

After pull (merge):
  local:   A --- B --- C --- M  (main)
                  \         /
                   --- D ---

git fetch vs git pull

  • git fetch — Downloads changes but does NOT merge. Safer — you can review first.
  • git pull — Downloads AND merges. Convenient for simple cases.

Try it!

Simulate getting updates from a teammate:

  1. Check current state: git log --oneline
  2. Pull the latest changes: git pull origin main
  3. See the new commits: git log --oneline
  4. Check the files: ls

Best Practices

  • Pull before push — Always pull to get the latest changes before pushing your own
  • Use fetch when unsure — git fetch + review + git merge gives you more control
  • Pull with rebase — git pull --rebase keeps a linear history (avoids merge commits)
🎯

Goal

Pull the latest changes from origin that your teammate pushed

Terminal
$

No commits yet. Run `git init` and create your first commit.