Git FAQ

Frequently asked questions around Git and Version Control.

git fetch - Downloading Data from a Remote

The "fetch" command is indispensable for staying up-to-date in a project: only when performing a "git fetch" will you be informed about the changes your colleagues pushed to the remote server.

git fetch Updates Your View of Remote Data

Before we talk about "git fetch" itself it's really important to understand how remote data is managed in Git.

When looking at your remote branches and commits, you must keep in mind that you're looking at a "snapshot" of data. There is no "live" connection to your remote server. Instead, Git saves the latest information about your remotes each time a "fetch" operation is performed. This means that the information about remote branches and commits that you see is only as fresh as the last snapshot you fetched.

To see new remote branches, commits, tags, etc., you have to explicitly tell Git to download this information - with "git fetch".


Tip

Automatic Fetching in Tower

In case you are using the Tower Git client, you don't have to fetch manually: Tower automatically performs a Fetch from time to time in the background for you.

Fetch Does Not Integrate

Fetch is probably one of the most harmless commands in Git: although it downloads data to your local repository, it does not integrate any of that data into your local branches or working copy. Fetch really only updates your view on remote data.

It's up to you to later integrate any of the new data into your local project.

git fetch in Action

The actual syntax of a Fetch command is dead simple: "git fetch" and the name of the remote server is all we need.

$ git fetch origin

A useful parameter, however, is "prune": this tells Git to remove any references to branches that no longer exist on the remote. This ensures that you don't look at stale data:

$ git fetch origin --prune

Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.