一、切換分支(方式一)
- 查看遠(yuǎn)程分支
git branch -a
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/nnvm
remotes/origin/piiswrong-patch-1
remotes/origin/v0.9rc1
2斋攀、查看本地分支git branch
$ git branch
* master
3、切換分支git checkout -b v0.9rc1 origin/v0.9rc1
$ 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'
#已經(jīng)切換到v0.9rc1分支了
$ git branch
master
* v0.9rc1
#切換回master分支
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
二梧田、切換分支(方式二)
git fetch
git checkout v0.9rc1
三淳蔼、cherry-pick
它可以選擇某一個(gè)分支中的一個(gè)或幾個(gè)commit(s)來進(jìn)行操作(操作的對象是commit)。
首先切換到你要添加commit的分支裁眯,如:你要將A分支上面的commit添加到B分支上面鹉梨,我們可以要先切換到B分支上面(它是一個(gè)本地的操作,假如你pull代碼之后有人在A分支上有了新的commit穿稳,需要你先在A分支pull代碼再在B分支進(jìn)行cherry-pick)存皂。
git checkout B
然后把A分支的某個(gè)commit合并到B分支:
git cherry-pick 0771a0c107dbf4c