I cannot be sure, because I am not the author of this proposal. I will take a picture that the confusion that the author describes is a common confusion between the branches of "tracking" and "remote tracking". gitguys has a great article about this, so really, you should just read this. They have beautiful photos and that’s it.
Here I take it upon myself ...
Customization
As an example, suppose we have a very simple git repository on github that has a single master branch with several commits (C1 and C2, where C2 is the current commit). When you clone this repository ...
git clone git@github.com :example/repo.git
... two things happen:
- Copy all the commits (C1 and C2) to the local computer.
- You also create a new branch on the local computer called
master . This branch is a "tracking branch", and its HEAD is located on C2. This branch is called the "tracking branch."
New commit
Nothing special yet. But while you read these explanations, someone committed another commit (C3) and clicked it on the remote repository. Now imagine that you hear about this exciting new commit and decide to get it yourself.
git fetch
This does two things:
- Copy the new commits that are needed (C3) to your local computer.
- Updates the local system to inform them that the start branch of
master now in C3.
But the question is: how does the local system know that the origin branch of master is in C3? Does git really have some way to store this information locally? But where? We cannot make changes to the local master branch, since we can have our own commits or other changes in this local branch that we need to merge. Is it just stored in some other unknown block?
Answer
It turns out git just uses the third branch. Right now, we knew about two branches:
- The branch is physically located on github.
- "Tracking" located on your computer (what would you call
master ).
It turns out there is a third. You have probably seen it before: it is called origin/master . And this is not the same as none of these two branches. This is what is known as the "remote tracking branch".
You can think of it as a branch, which is located between the local branch of your master and branch master . This is the actual git branch on your computer (just like master ), and as such you can play with it just like you can jump in other branches. However, there are limitations.
For example, you can check this ...
git checkout origin/master
However, you will get a funny message ...
Note: checking out 'origin/master'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at 12dbe6a... My awesome commit!
This message is displayed because the "remote tracking branches" are READABLE. The user cannot manipulate them as they can master , only the git system itself can make changes to it (which it will do during the selection). Thus, from the point of view of implementation, you can think of them as any other industry. However, because of their read-only principle, you usually don't use them like any other branch.
So, we have three branches in the mix:
- The branch is physically located on github.
- An
origin/master branch physically located on your computer ("remote tracking branch"). - A
master branch physically located on your computer ("tracking branch").
The answer to the question ...
Therefore, my assumption is that in fact, confusion may lie between the branches of "tracking" and "remote tracking". It would be prudent that someone would confuse master as a “remote tracking branch” (in the end, it gets a commit from origin/master !), But actually it is not. This is the "tracking branch" and its branch is origin/master . origin/master is the "remote tracking branch".
When someone talks about “tracking” in terms of git branch -track, they talk about a “tracking” branch that you can change.
When someone talks about “remote tracking branches”, they talk about a read-only branch that tracks the remote branch.