This question arises when learning Pro git "remote branch".
Question:
When git fetch grabs the remote tracking branch, will it generate a local copy?
Read the original explanation first,
To synchronize your work, run the git fetch origin command. This command finds which server "origin" is (in this case, it is git.ourcompany.com), fetches data from it that is not available locally, and updates the local database, moving the origin/master pointer to point to the new, updated Location.
From the picture, because the master branch is local, after cloning the remote warehouse (f4265 submission point), two local submissions were made, generating a new submission chain. At the same time, someone else on the server pushed the master branch (31b8e, 190a3) that was submitted to the server. Therefore, when using git fetch origin, my understanding is:
The local master branch will not be affected, from the fork Starting from origin/master before fetch, a new branch is generated locally. This branch does generate a copy locally, and at the same time, the origin/master pointer points to the end of the local copy.
But after reading below, here comes another paragraph:
One thing to pay special attention to is that when a new remote tracking branch is captured, an editable copy (copy) will not be automatically generated locally. In other words, in this case, there will not be a new serverfix branch - just an unmodifiable origin/serverfix pointer.
I don’t understand. Is my previous understanding wrong? So the illustration in Figure 32 is also wrong? The two commit points (31b8e, 190a3) will not be obtained locally at all, but only a new origin/master pointer will be obtained in the database? The main original text says "grab data that is not available locally and update the local database" is very vague, and it doesn't say what the data is.
给我你的怀抱2017-06-22 11:54:57
Nothing wrong.
Catch data that is not available locally, and update the local database, moving the origin/master pointer to the new, updated location.
Focus on this, this branch is master.
When a new remote tracking branch is fetched, the local branch will not automatically generate an editable copy (copy). In other words, in this case, there will not be a new serverfix branch - just an unmodifiable origin/serverfix pointer.
So, you need to use git checkout -b serverfix origin/serverfix
to create an editable local copy.
Only the master branch will create an editable local copy. Other branches are under origin/*
and require manual git checkout -b
.