Lesson 10
Fetch
Fetch downloads remote history so you can inspect it without changing your current branch.
Visual Explanation
Ready to run git fetch --prune origin.
Keep These Ideas
- Download only
- Your files and local main branch do not move.
- origin/main
- Your local Git's latest known position for main on origin.
- Inspect first
- Compare incoming commits before deciding how to integrate them.
The Real Command
Terminal
git fetch --prune originExample Output
From https://gitlab.com/acme/shop
a1b2c3d..d4e5f6a main -> origin/main
- [deleted] (none) -> origin/old-demogit fetch downloads origin's latest history. --prune also removes local labels for remote branches that no longer exist.
Command Details
git fetch originFetch one remote. It updates remote-tracking labels such as origin/main.
Example Output
From https://gitlab.com/acme/shop
a1b2c3d..d4e5f6a main -> origin/maingit log main..origin/main --onelineTwo dots compare endpoints. This lists commits origin/main has that local main does not.
Example Output
d4e5f6a Add login validation
b2c3d4e Build login formKnowledge Check
Inspect Remote Work Safely
Download updated remote knowledge without changing your current branch.
Question 1 of 5
- Question 1: current
- Question 2: not started
- Question 3: not started
- Question 4: not started
- Question 5: not started