git 查看本地分支和远程分支,创建本地分支,创建远程分支,本地分支对应的远程分支相关联

查看本地分支和远程分支命令

$ git branch -a

[hhb@MANI tgmm-hhb-m]$ git branch -a
  master
  tgmm-dev
* tgmm-dev-temp
  remotes/origin/master
  remotes/origin/tgmm-dev

git查看本地分支关联的远程分支

$git branch -vv

[hhb@MANI tgmm-hhb-m]$ git branch -vv
  master        d417cc4 [origin/master] changed to getNumNodes_Omp()
  tgmm-dev      07e4d68 [origin/tgmm-dev] code arrange 2017.4.20
* tgmm-dev-temp 59214f5 start multi-threads in tracking

创建分支test

$git branch test

切换到分支test

$git checkout test

把分支推送到远程

$git push origin test 这样远程仓库中也就创建了一个test分支

参考 http://blog.csdn.net/arkblue/article/details/9568249/
https://www.cnblogs.com/a-flydog/p/5520999.html

将新创建的分支与远程分支相关联
以我新创建的
tgmm-dev-temp分支为例子

[hhb@MANI tgmm-hhb-m]$ git branch -vv
  master        d417cc4 [origin/master] changed to getNumNodes_Omp()
  tgmm-dev      07e4d68 [origin/tgmm-dev] code arrange 2017.4.20
* tgmm-dev-temp 59214f5 start multi-threads in tracking

使用命令

$ git branch –set-upstream tgmm-dev-temp origin/tgmm-dev-temp

参考http://www.tuicool.com/articles/vQ36Zj

[hhb@MANI tgmm-hhb-m]$ git branch --set-upstream tgmm-dev-temp origin/tgmm-dev-temp 
Branch tgmm-dev-temp set up to track remote branch tgmm-dev-temp from origin.

现在再查看本地分支和远程分支关联的情况

[hhb@MANI tgmm-hhb-m]$ git branch -vv
  master        d417cc4 [origin/master] changed to getNumNodes_Omp()
  tgmm-dev      07e4d68 [origin/tgmm-dev] code arrange 2017.4.20
* tgmm-dev-temp 59214f5 [origin/tgmm-dev-temp] start multi-threads in tracking

OK了

你可能感兴趣的:(git)