What is a tracking link?

When I push a new branch to a remote repository through Git Extensions, I get a warning that

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 link? I found only a few mentions of tracking links on Google and no real definition.

+46
git git-extensions
Mar 13 '13 at 1:01
source share
3 answers

The basic idea is that there are purely local links (e.g. branches, tags), and then there are remote tracking links that follow what happens in other repositories. Since Git is decentralized, you can choose a name for the branch that matches the name used remotely, without knowing anything else so that they have a completely different job to do with them. Git allows you to do this, but also provides a way to associate local links with remote links.

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 next branch, which tracks the remote branch with the same name and the local todo branch, which will not be updated with changes to remotes/origin/todo .

+19
Mar 13 '13 at 3:46
source share

Nick Quaranto a great git ready blog has a post explaining remote tracking branches :

Remote tracking tracking has several different purposes:

  • Theyre used to communicate that you are working locally, compared to what is on the remote control.

  • They will automatically know which remote branch will receive the changes from when you use git pull or git fetch.

  • Even better, git status will recognize it, how much you commit before the remote version of the branch.

+4
01 Oct '13 at 4:21
source share

The local git branch can track the remote branch, which means that the w2> push and git commands will know to pull and pull the commits to and from the tracked branch by default. Also, git status will indicate the status between your current local branch and the remote branch that it is tracking. When you clone a git repository, git will add a tracking link to the local branch of the wizard to track the remote main branch. When you check out a new branch of remote access, git will add a tracking link to the created local branch to track the remote branch that you checked.

However, if you create a new branch locally and then paste it into the remote repository, you need to explicitly specify git if you want your local branch to start tracking the new remote branch. You do this with the -u or --set-upstream option when pushing the local branch to the remote repository: git push -u origin my-new-branch .

You can check which remote branches are tracking your local branches (if any) with the git branch -vv command The following is a small sample output.

  b1 560eb64 Added file.txt b2 560eb64 [origin/b2] Added file.txt b3 b638c18 [origin/r1: ahead 1] Added file3.txt * master 560eb64 [origin/master] Added file.txt 

In this case, we have local branches master , b1 , b2 and b3 . In the master branch, the remote branch named master is tracked, branch b1 does not track the remote branches, branch b2 tracks the remote branch named b2 , and branch b3 tracks the remote branch named r1 . git branch -vv also shows the status of the branch associated with the branch being tracked. Here, branch b3 is 1 commit ahead of the tracked remote branch, and the rest of the branches are updated with the corresponding remote tracked branches.

So, if you create a local branch and click on the remote repository, do you want to add a tracking link to the branch or not? Usually, when you push a new local branch to a remote repository, you do this to collaborate with other developers in this function. If you add a tracking link to your local branch, you can easily extract the changes that other people have made to the branch, so I would say that in most cases you want to add a tracking link.

+3
Jan 18 '16 at 19:00
source share



All Articles