Reputation: 753
Till now what I know from my previous usages is that,
git checkout -b branchName
creates a new branch and switches the branch to branchName
the new component origin/master is the part I have got no clue about.
Note: while solving a merge conflict gitHub suggested the following
git checkout -b master origin/master
Can anyone explain what is the role of this argument & what '/' does there?
Upvotes: 1
Views: 3265
Reputation: 2272
Let's assume, on your remote git repository (named origin
), you have a branch rbranch
, then:
git checkout -b lbranch origin/rbranch
will create lbranch
and track origin/rbranch
. i.e.
Create the lbranch
branch (if not already created) and track the
remote tracking branch origin/rbranch
.
Or reset lbranch
(if
already created) to the point referenced by origin/rbranch
.
Since master
is the default branch and already tracks origin/master
, the below command:
git checkout -b master origin/master
will checkout master
. And will reset the local master
branch to the same head remote branch in on (if they were on different heads).
Tracking means that a local branch has its upstream set to a remote branch. More here.
Upstream means communication from local to remote. More here.
Upvotes: 1
Reputation: 4983
it simply separate between the remote (the repo) to the branch name
git checkout -b <branch> <remote>/<branch>
it sets the upstream of the new branch, without using this option e.g
git checkout -b <branch>
the branch is only created locally without upstream attached at the server you can find more info here https://git-scm.com/docs/git-checkout
Upvotes: 1