Teacher Liao Xuefeng’s git tutorial says this:
But why does it look like this after I perform the operation?
Also, I don’t quite understand this command. Which of the following does Teacher Liao mean? Or neither?
1. The dev branch already exists remotely. What does this command mean to create a dev branch locally and clone the contents of the remote dev branch locally? ? ?
2. The remote does not have a dev branch yet. This command means to create a dev branch locally and remotely at the same time???
I am new to git, please give me some advice
dev
前面 有origin
分支全名是origin/dev
As the name suggests, the remote one dev
分支,checkout -b
is a new branch, followed by the name of the new branch.
git checkout --help
You can see the basic information
For the former, if this branch does not exist on the remote end, it will not be created. You can practice it
First of all, neither of the two guesses you listed are quite right.
Actually, Liao Da said it very clearly:
You must create the dev branch of the remote origin to the local
So the premise for you to use that command is that the remote dev branch already exists.
The function of that command is also very simple. It is to create a local branch that tracks the remote branch. That is, first build a branch locally, and then set the remote branch to be tracked for it. It is not redundant as the poster said. operation.
Secondly, I think what makes the poster confused is these local branches:
These branches are the branches that appear after you synchronize with the remote (git push, git fetch, git pull) and other operations. They are equivalent to the references of the remote branch. In layman's terms, these local references can represent the remote branch.
The operation of the command git checkout -b develop origin develop
mentioned by the poster is based on these references, so even if your computer is currently offline (not connected to the network), it can still work normally. The reason is simple, this command only operates on references to remote branches, and these references are located locally.
First, your ordersgit checkout -b develop origin develop
是錯(cuò)誤的,因此才會(huì)報(bào)這樣的錯(cuò)誤,注意origin和develop之間是要有/
的。因此,正確的命令是git checkout -b develop origin/develop
我對(duì)該命令的理解是:本地新建一個(gè)分支develop,并切換到新建的分支develop,并且建立develop與遠(yuǎn)程分支origin/develop的跟蹤關(guān)系。查看本地分支的跟蹤分支(上游分支)命令:git branch -vv
.