Skip to main content

Command Palette

Search for a command to run...

What’s the difference between git fetch and git pull?

Published
2 min read
What’s the difference between git fetch and git pull?
I
Azure Cloud Data & AI Solution Engineer specializing in Microsoft Fabric, Power BI, data architecture, governance, and modern data platforms.

git fetch vs git pull

Both commands are used to download new data from a remote repository but what’s the difference between the two?

Downloading the latest data is a critical step in your daily work because the data that you have in your local repository is only a “snapshot” as per your last “fetch” or “pull”. Make sure to keep this in mind when inspecting remote branches and commits!

Fetch

$ git fetch origin

git fetch only downloads new data from a remote repository — but it doesn’t integrate any of this new data into your working files. Fetch is great for getting a fresh view on all the things that happened in a remote repository.
Due to it’s “harmless” nature, you can rest assured: fetch will never manipulate, destroy, or screw up anything.

Pull

$ git pull origin master

git pull, in contrast, is used with a different goal in mind: to update your current HEAD branch with the latest changes from the remote server. This means that pull not only downloads new data; it also directly integrates it into your current working copy files. This has a couple of consequences:

  • Since “git pull” tries to merge remote changes with your local ones, a so-called “merge conflict” can occur.

  • Like for many other actions, it’s highly recommended to start a “git pull” only with a clean working copy. This means that you should not have any uncommitted local changes before you pull. Use Git’s Stash feature to save your local changes temporarily.