If everyone is collaborating together, others may have pushed other branches to the central warehouse, but you will not be able to see them locally at this time. For example, it turned out to be only the master分支,另外一个人推送了f1 branch. This time in your local area,
λ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
Directly execute the switch branch to f1,
λ git checkout f1
error: pathspec 'f1' did not match any file(s) known to git.
Of course it’s not possible. So what should you do?
I’m not sure how the specific code is stored, I haven’t researched it. But switching this function should not download all the code. The local code should be detected first, and then the code that is not available locally should be downloaded. The code that is available locally should not be downloaded. If you observe carefully, when a project has a large amount of code, it takes a lot of time to clone it for the first time, but switching branches is much faster. Although the code and branches remain consistent, it doesn't feel like all the code is re-downloaded every time.
Unless your local version is the latest, if not you still need to execute it yourselfgit pull origin 分支 to synchronize to the latest version under the corresponding branch
All the branch codes are available locally. Everyone’s warehouse is a clone of each branch version. They are exactly the same, otherwise they would be called clones.
If everyone is collaborating together, others may have pushed other branches to the central warehouse, but you will not be able to see them locally at this time.
For example, it turned out to be only the
master
分支,另外一个人推送了f1
branch.This time in your local area,
Directly execute the switch branch to
f1
,Of course it’s not possible.
So what should you do?
You can remove the central branch information
This way you can switch branches happily
You are already branching in
f1
at this time,*
in front indicates the branch currently pointed to by the local.It seems yes, you can cut it
I’m not sure how the specific code is stored, I haven’t researched it. But switching this function should not download all the code. The local code should be detected first, and then the code that is not available locally should be downloaded. The code that is available locally should not be downloaded. If you observe carefully, when a project has a large amount of code, it takes a lot of time to clone it for the first time, but switching branches is much faster. Although the code and branches remain consistent, it doesn't feel like all the code is re-downloaded every time.
Unless your local version is the latest, if not you still need to execute it yourself
git pull origin 分支
to synchronize to the latest version under the corresponding branchAll the branch codes are available locally. Everyone’s warehouse is a clone of each branch version. They are exactly the same, otherwise they would be called clones.
After switching branches, you need to pull the latest code from the server