git命令-切換分支

git通常有不少分支,咱們clone到本地的時候通常都是master分支,那麼如何切換到其餘分支呢?主要命令以下:git

1. 查看遠程分支bash

$ git branch -a
我在mxnet根目錄下運行以上命令:code

~/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

能夠看到,咱們如今在master分支下rem

2. 查看本地分支it

~/mxnet$ git branch
* master

3. 切換分支ast

$ 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'.
相關文章
相關標籤/搜索