Fetch

There are three main operations when dealing with a remote: fetch, pull and push. These operations are all at the branch level. In other words, there's always a source branch and a receiving branch.

Let's look at fetch first. If you look up the definition, it says "the process of downlinking changes from remote to the tracking branch is called a fetch". But what is a tracking branch?

Tracking branches

When a fetch is done, the changes sets are downloaded from the remote and stored locally. These changes are NOT merged into your branch yet. Instead, Git stores them in a remote tracking branch. These branches can only be edited by Git during a inter-repo communication.

Fetch syncs the tracking branch with the remote. Here origin/dev is the tracking branch for dev on the remote. But the local dev remains unchanged

The tracking branch serves as a local mirror of the remote. In good practice, one should fetch regularly so that the tracking branches are updated frequently. This way, even you 're on a plane you can still merge some work.

In conclusion, a fetch syncs the tracking branch with the remote. At this point, these changes are not on your local branches yet. To include these changes, you have to do a merge.

Last updated