github - git checkout -b develop origin develop ?
習慣沉默
習慣沉默 2017-05-02 09:52:22
0
4
994

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

習慣沉默
習慣沉默

reply all(4)
迷茫

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 --helpYou 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.

Peter_Zhu

First, your ordersgit checkout -b develop origin develop是错误的,因此才会报这样的错误,注意origin和develop之间是要有/的。因此,正确的命令是git checkout -b develop origin/develop
我对该命令的理解是:本地新建一个分支develop,并切换到新建的分支develop,并且建立develop与远程分支origin/develop的跟踪关系。查看本地分支的跟踪分支(上游分支)命令:git branch -vv.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template