1.查看分支
查看本地仓库所有分支
$ git branch
V1.8.0.local
V1.8.1
* V1.8.2
master
2.查看本地和远端仓库所有分支
git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/V1.3
remotes/origin/V1.3.3
remotes/origin/V1.4
remotes/origin/V1.6.0
remotes/origin/V1.7.0
remotes/origin/V1.8.0
remotes/origin/V1.8.1
remotes/origin/V1.8.2
说明: 分支名称V1.8.2 并不包括 remotes/origin remotes只是说明是远程仓库 origin 是远程仓库的别名
3. 下载远端仓库中的分支到本地新的分支(如果本地分支不存在,则新建分支)
$ git checkout -b local-branchname origin/remote_branchnam
4. 创建本地分支
$ git branch localBranchName
5.切换本地分支
$ git checkout localbranchName
6. 上传本地分支到远程分支(远程分支不存在则创建新的分支)
git push origin localBranchName:remoteBranchName
说明:remoteBranchName不需要加remotes/origin eg: git push origin V1.8.2