How do git clone, fetch, pull and pull --rebase differ?
Short answer
clone creates a local repo from a remote, once. fetch only downloads and updates origin/main, not touching your branch or edited files. pull = fetch + merge; pull --rebase = fetch + rebase, giving a straight history.
3 points to say:
fetchis always safe: it only updates remote-tracking branches; inspect withgit log HEAD..origin/mainbefore integrating.pull= fetch + merge,pull --rebase= fetch + rebase (no extra merge commit).- Set
pull.rebase truefor personal branches; rebase rewrites unpushed local commits, never rebase commits others build on.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.