Typorithm · medium

fetch, pull & tracking

git-fetch-pullgitfetchpullupstream
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn fetch, pull & tracking

0%

Remote & Collab

git fetch downloads remote commits without changing your branch; git pull is fetch + merge (or fetch + rebase with --rebase for a linear history); git branch -u sets the upstream tracking branch; origin/main..HEAD lists commits you have that the remote lacks.

git fetch downloads new commits and updates remote-tracking refs like origin/main, but leaves your working branch untouched — it is the safe way to see what changed upstream.

git pull is fetch followed by a merge of the upstream into your branch. Adding --rebase replays your local commits on top of the fetched ones instead of merging, keeping history linear.

git branch -u origin/main sets the upstream so pull and push know the remote branch. The range origin/main..HEAD shows the commits on HEAD that are not yet on the remote.

01

fetch downloads commits; it does not merge.

02

pull = fetch + merge (or + rebase with --rebase).

03

branch -u sets the upstream tracking branch.

git fetch origin
git pull
git pull --rebase
git branch -u origin/main
git log origin/main..HEAD

Read the implementation

Connect each part of the code to the concept before you type.

1. Download commits

git fetch downloads new commits from origin without touching your working branch.

git fetch origin

2. Fetch + merge

git pull fetches and then merges the upstream into your current branch.

git pull

3. Fetch + rebase

--rebase replays your commits on top of the fetched ones for a linear history.

git pull --rebase

4. Set upstream

branch -u points the current branch at origin/main as its tracking branch.

git branch -u origin/main

5. Commits ahead

origin/main..HEAD lists commits you have locally that the remote does not.

git log origin/main..HEAD

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

fetch, pull & tracking: Lesson & Practice · Typorithm | ApplyDjinn