What is the difference between git fetch and git pull?
Quick Answer
git fetch downloads new commits from the remote into your remote-tracking branches (origin/main) but doesn't touch your working branch. git pull is fetch + merge (or fetch + rebase with --rebase) — it also integrates those changes into your current branch.
git fetch just downloads the latest commits from the remote and updates my remote-tracking branch like origin/main, without changing my working branch — so I can look at what's incoming first. git pull does the fetch and then immediately merges those changes into my current branch, so it's two steps in one. I often configure pull to rebase instead of merge, so my local commits get replayed on top of the updated remote and I don't get a noisy merge commit.
fetchthengit log main..origin/mainlets you review incoming changes before merging.git pull --rebase(orpull.rebase = true) replays your local commits on top of the remote, avoiding a merge commit — cleaner history for a feature branch.- A plain
git pullon a branch you've also committed to creates a merge commit.