Git fetch: download without merging
git fetch downloads changes from the remote repository without touching your local code. You can inspect the changes before deciding what to do with them.
What is git fetch?
git fetch downloads changes from the remote repository without merging them into your local code. Unlike git pull, it doesn't modify your working directory.
It's like checking your tracking number without opening the package. You know what has arrived, but you decide when and how to integrate it.
Git fetch syntax
git fetch originDownload everything from origin
git fetch origin mainDownload only the main branch
git fetch --allDownload from all remotes
Git fetch in practice
Download changes, inspect then merge.
Basic fetch
Inspect then merge
git fetch vs git pull
git fetch
Downloads remote changes without merging them. Your local code stays intact.
git pull
Performs a fetch then a merge automatically. Faster but less control.
Common mistakes with git fetch
Thinking fetch updated your code
Fetch does not modify your local files. After a fetch, you still need to run git merge origin/main to integrate the changes.
Forgetting to merge after fetch
If you fetch but never merge, your local branch falls behind. Remember to merge regularly.
Confusing local and remote branches
After a fetch, origin/main is up to date but main (local) is not. These are two different references.
Part of the Git Remote & Collaboration guide
GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.
Questions about git fetch
Explore remote workflows with GitQuest
Learn to navigate between local and remote through GitQuest challenges.
Start the investigations