gitgit-extensions

What is a Tracking Reference?


When I push a new branch up to a remote repository via Git Extensions, I get an alert saying

The branch {branch name} does not have a tracking reference. Do
you want to add a tracking reference for {branch name}?

What is a tracking reference? I've found only a few mentions of tracking references in Google and no real definition.


Solution

  • The basic idea is that there are purely local references (e.g., branches, tags), and then there are remote tracking references, which follow what happens in other repos. Because Git is decentralized, it is possible for you to choose a name for a branch that is the same as one used in a remote, without having known about the other one, such that they have completely different work on them. Git lets you do this, but it also provides a way to link local references to remote ones as well.

    For example, consider the following:

    % git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      remotes/origin/maint
      remotes/origin/master
      remotes/origin/next
      remotes/origin/pu
      remotes/origin/todo
    

    Here we have branches on origin called next and todo.

    % git checkout -t remotes/origin/next
    Branch next set up to track remote branch next from origin.
    Switched to a new branch 'next'
    % git branch todo    
    

    Now we have a local branch next that tracks the remote branch of the same name and local branch todo that will not be updated with changes to remotes/origin/todo.