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:
git fetch: Downloads new commitsgit 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
- Pull before starting work each day
- Pull before pushing
- Commit your work before pulling
- Pull frequently to avoid conflicts
Workflow Tip
Many developers follow this pattern:
- Start day:
git pull - Work on code
- Commit changes
- Before push:
git pull - Resolve any conflicts
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!