Fetch versus Pull
git fetch downloads new commits without touching your branch. git pull is fetch plus merge (or rebase). Fetch first when you want to look before merging.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
git init -q --bare -b main ../o.git && git remote add origin ../o.git && git push -q -u origin main
cd .. && git clone -q o.git other && cd other
git config user.name Bob && git config user.email b@x.com
echo two >> a.txt && git commit -qam 'from bob' && git push -q
cd ../repo
git fetch -q
git log --format=%s origin/main | head -1
git log --format=%s | head -1
git pull -q
git log --format=%s | head -1Result
from bob first from bob
Exercise
Download without merging.
git Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.