What's the difference between `git fetch`, `git pull`, and `git push`?
Show answer — try answering out loud first
git push uploads your local commits to the remote. git fetch downloads the changes from the remote but does not integrate them into your branch; it only updates your knowledge of the remote. git pull downloads and integrates in a single step: it's a fetch followed by a merge (or rebase).
These three commands move commits between your local repo and the remote.
git push: sends your local commits to the remote so others can see them.git fetch: downloads the new commits from the remote and updates the remote-tracking branches (origin/main), but doesn't touch your local branch. Your work stays intact; you just find out what's new. It's the safe option for "look before integrating."git pull: runsgit fetchand also integrates those changes into your current branch (by default with merge). It's convenient but can cause conflicts or unexpected merges.
The key difference between fetch and pull: fetch only looks, pull looks and applies.
# Upload your local commits to the remote
git push
# or specifying a branch: git push origin main
# Download the remote's changes WITHOUT integrating them (safe)
git fetch origin
# Now origin/main is up to date, but your local branch didn't change
git log origin/main --oneline # you can review what arrived
# Integrate manually after the fetch
git merge origin/main
# Download AND integrate in a single step
git pull
# equivalent to: git fetch + git merge
# Download and integrate using rebase instead of merge
git pull --rebase
Running git pull blindly when you have uncommitted local changes or when the branch has diverged, and getting hit with a conflict or a surprise merge. Many teams prefer git fetch + review + integrate, or git pull --rebase to keep the history linear. Another mistake: confusing fetch with pull, thinking fetch already updated your working branch (it doesn't).
"
git pushuploads my commits to the remote.git fetchdownloads the remote's changes but doesn't integrate them: it only updates the remote-tracking branches likeorigin/main, so I can review before applying anything.git pullis afetchplus amergein a single step: it downloads and integrates directly into my branch. The key difference is thatfetchonly looks andpulllooks and applies. Sometimes I preferfetchand then integrating by hand, orpull --rebaseto keep the history linear."
You want to see what changes your teammates pushed to the remote, but without touching your local work yet. fetch or pull?
See answer
git fetch. It downloads the new commits and updates the remote-tracking branches (like origin/main) without modifying your local branch, so you can review calmly (for example with git log origin/main) before deciding to integrate them with merge or rebase. git pull would apply them to your branch immediately, which is exactly what you want to avoid in this case.