The git command-switch branches generally have many branches, when we clone to the local are generally master branches, so how to switch to other branches? The main commands are as follows:

Git generally has many branches. When we clone to the local, it is usually the master branch, so how to switch to other branches? The main commands are as follows:

1. View remote branches

$ git branch -a 
I run the above command in the root directory of mxnet:

~/mxnet$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/nnvm
  remotes/origin/piiswrong-patch-1
  remotes/origin/v0.9rc1

As you can see, we are now under the master branch

2. View local branches

~/mxnet$ git branch
* master

3. Switch branches

$ git checkout -b v0.9rc1 origin/v0.9rc1
Branch v0.9rc1 set up to track remote branch v0.9rc1 from origin. Switched to a new branch 'v0.9rc1' #已经切换到v0.9rc1分支了 $ git branch master * v0.9rc1 #切换回master分支 $ git checkout master Switched to branch 'master' Your branch is up-to-date with 'origin/master'.

1. View remote branches

$ git branch -a 
I run the above command in the root directory of mxnet:

~/mxnet$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/nnvm
  remotes/origin/piiswrong-patch-1
  remotes/origin/v0.9rc1

As you can see, we are now under the master branch

2. View local branches

~/mxnet$ git branch
* master

3. Switch branches

$ git checkout -b v0.9rc1 origin/v0.9rc1
Branch v0.9rc1 set up to track remote branch v0.9rc1 from origin. Switched to a new branch 'v0.9rc1' #已经切换到v0.9rc1分支了 $ git branch master * v0.9rc1 #切换回master分支 $ git checkout master Switched to branch 'master' Your branch is up-to-date with 'origin/master'.

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/12677613.html