The Difference between Git Fetch and Pull

What is the Difference between Git Fetch and Pull?

Hi Techies,

In this blog post, we are going to discuss the difference between Git Fetch and Pull.

You might already be aware that .NET developers generally use TFS (Team Foundation Server) as source control. However, GIT is also an awesome source control tool being used by many organizations working on Microsoft technologies these days.

What is GIT?

Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Difference between Git Fetch and Pull

Difference between Git Fetch and Pull

Let’s now look at very fine but important differences between “fetch” and “pull”.

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 of all the things that happened in a remote repository.

Due to its harmless nature, you can be assured that fetch will never manipulate, destroy, or screw up anything. This means you can never fetch often enough.

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 but 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.

Hopefully, after reading this post you are able to understand the difference between Git Fetch and Pull.

Share with your friends:

Leave a Comment

Your email address will not be published. Required fields are marked *