less than 1 minute read

This is a misconception that I’ve seen or heard many times, sometimes almost in those exact words.

Reality: git fetch downloads the actual commits from the remote repository. That’s the actual code versions, available locally. When you fetch, all commits from the remote branches are copied to your local repo, even if you won’t immediately see any changes in your local working copy of the code base.

Typical symptoms indicating the misconception:

  • A developer stashes the local changes and then git pulls to a temporary branch, when they actually just wanted to sync their remote tracking branches with the remote, which is done by git fetch. No need to stash or switch branches. Pull simply also does a fetch and then some more. Essentially, fetch does what many developers think pull does.
  • To check out a colleague’s feature branch, many devs create a new branch followed by a weird combination of merging and/or resetting, when what they actually just want to do is probably:
    git fetch\ git checkout origin/bobs-branch

This misconception often indicates bigger problems in a developer’s mental model of how Git works, especially regarding things like remotes and remote tracking branches and the distributed aspect of Git.