Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  1. Intermediate Concepts

Fetch

PreviousRebaseNextPull

Last updated 1 year ago

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.

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.

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