← Back to Mission Control

Receiving Updates

9 min read

Git Pull

Mission Phase 17 • Difficulty: Beginner

Downloading from Mission Control

While you work, teammates push changes to GitHub. Use git pull to download and integrate their work into yours.

The Pull Command

git pull

This downloads new commits and merges them into your current branch.

What Pull Actually Does

git pull is actually two commands:

  1. git fetch: Downloads new commits
  2. git merge: Merges them into your branch

You can run these separately for more control.

Fetch vs Pull

Fetch (Safe)

git fetch

Downloads changes but doesn't merge. Lets you review before integrating.

Pull (Convenient)

git pull

Downloads and merges in one step. Faster but less control.

Specifying Remote and Branch

git pull origin main

Pull with Rebase

git pull --rebase

Instead of merging, rebases your commits on top of the pulled changes. Creates cleaner history.

Handling Conflicts

If you and a teammate edited the same lines, Git can't auto-merge:

Auto-merging navigation.js
CONFLICT (content): Merge conflict in navigation.js
Automatic merge failed; fix conflicts and then commit.

Open the conflicted file. You'll see:

<<<<<<< HEAD
const speed = 1500;
=======
const speed = 2000;
>>>>>>> main

Edit to resolve, remove markers, then:

git add navigation.js
git commit

Best Practices

Workflow Tip

Many developers follow this pattern:

  1. Start day: git pull
  2. Work on code
  3. Commit changes
  4. Before push: git pull
  5. Resolve any conflicts
  6. git push

Viewing Remote Changes

After git fetch, compare with:

git log HEAD..origin/main    # See new commits
git diff HEAD origin/main     # See changes

Next: Parallel Timelines

You can now synchronize with teammates. Next, we'll explore Git's most powerful feature: branching!