git clone 所有分支到本地的方法

1. 克隆仓库,默认克隆下来的是master

$ git clone https://github.com/PX4/PX4-ECL.git
Cloning into 'PX4-ECL'...
remote: Enumerating objects: 10932, done.
remote: Counting objects: 100% (370/370), done.
remote: Compressing objects: 100% (180/180), done.
remote: Total 10932 (delta 224), reused 290 (delta 188), pack-reused 10562
Receiving objects: 100% (10932/10932), 26.57 MiB | 212.00 KiB/s, done.
Resolving deltas: 100% (7887/7887), done.
$ cd PX4-ECL/

2. 取所有分支并创建本地分支和远程分支的联系

执行下边这一行命令即可:

for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done

以下是执行的结果:

$ for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done
Branch 'Release_v1.10' set up to track remote branch 'Release_v1.10' from 'origin'.
Branch 'Release_v1.10.0' set up to track remote branch 'Release_v1.10.0' from 'origin'.
Branch 'Release_v1.11' set up to track remote branch 'Release_v1.11' from 'origin'.
Branch 'Release_v1.7.0' set up to track remote branch 'Release_v1.7.0' from 'origin'.
Branch 'accel-bias-divergence-debug' set up to track remote branch 'accel-bias-divergence-debug' from 'origin'.
Branch 'coverity_scan' set up to track remote branch 'coverity_scan' from 'origin'.
Branch 'dev-ekf-heading-reset-local' set up to track remote branch 'dev-ekf-heading-reset-local' from 'origin'.
Branch 'ekfOptFlowFixes' set up to track remote branch 'ekfOptFlowFixes' from 'origin'.
Branch 'flow_interface' set up to track remote branch 'flow_interface' from 'origin'.
Branch 'gnss-yaw-noise' set up to track remote branch 'gnss-yaw-noise' from 'origin'.
Branch 'gtest' set up to track remote branch 'gtest' from 'origin'.
Branch 'nomag_init' set up to track remote branch 'nomag_init' from 'origin'.
Branch 'pr-alphafilter_minor' set up to track remote branch 'pr-alphafilter_minor' from 'origin'.
Branch 'pr-covariance_partial_double' set up to track remote branch 'pr-covariance_partial_double' from 'origin'.
Branch 'pr-ecl_ekf_defines' set up to track remote branch 'pr-ecl_ekf_defines' from 'origin'.
Branch 'pr-ecl_float_t' set up to track remote branch 'pr-ecl_float_t' from 'origin'.
Branch 'pr-ekfBadImuHgtReset' set up to track remote branch 'pr-ekfBadImuHgtReset' from 'origin'.
Branch 'pr-ekfCovarianceFix' set up to track remote branch 'pr-ekfCovarianceFix' from 'origin'.
Branch 'pr-ekfSymPyDerivationConversion' set up to track remote branch 'pr-ekfSymPyDerivationConversion' from 'origin'.
Branch 'pr-ekfSymPyMagFusionAlt' set up to track remote branch 'pr-ekfSymPyMagFusionAlt' from 'origin'.
Branch 'pr-ekfYawFailDetect' set up to track remote branch 'pr-ekfYawFailDetect' from 'origin'.
Branch 'pr-ekf_buffer_allocate' set up to track remote branch 'pr-ekf_buffer_allocate' from 'origin'.
Branch 'pr-ekf_covariance_double_hacks' set up to track remote branch 'pr-ekf_covariance_double_hacks' from 'origin'.
Branch 'pr-ekf_init_no_baro' set up to track remote branch 'pr-ekf_init_no_baro' from 'origin'.
Branch 'pr-ekf_initialise_filter_baro_mag' set up to track remote branch 'pr-ekf_initialise_filter_baro_mag' from 'origin'.
Branch 'pr-ekf_output_predictor_hacks' set up to track remote branch 'pr-ekf_output_predictor_hacks' from 'origin'.
Branch 'pr-ekf_update_interval_parameter' set up to track remote branch 'pr-ekf_update_interval_parameter' from 'origin'.
Branch 'pr-ekf_vel_test_ratio' set up to track remote branch 'pr-ekf_vel_test_ratio' from 'origin'.
Branch 'pr-estimator_status_flags' set up to track remote branch 'pr-estimator_status_flags' from 'origin'.
Branch 'pr-ev_rng_aid' set up to track remote branch 'pr-ev_rng_aid' from 'origin'.
Branch 'pr-float_t' set up to track remote branch 'pr-float_t' from 'origin'.
Branch 'pr-geo_globallocal' set up to track remote branch 'pr-geo_globallocal' from 'origin'.
Branch 'pr-geo_split' set up to track remote branch 'pr-geo_split' from 'origin'.
Branch 'pr-globallocal_purge' set up to track remote branch 'pr-globallocal_purge' from 'origin'.
Branch 'pr-gps-yaw-simplification' set up to track remote branch 'pr-gps-yaw-simplification' from 'origin'.
Branch 'pr-indoor_mag_hacks' set up to track remote branch 'pr-indoor_mag_hacks' from 'origin'.
Branch 'pr-l1-velocity-control' set up to track remote branch 'pr-l1-velocity-control' from 'origin'.
Branch 'pr-l1_updates' set up to track remote branch 'pr-l1_updates' from 'origin'.
Branch 'pr-mag-fusion-restart' set up to track remote branch 'pr-mag-fusion-restart' from 'origin'.
Branch 'pr-matrix_init' set up to track remote branch 'pr-matrix_init' from 'origin'.
Branch 'pr-namespace' set up to track remote branch 'pr-namespace' from 'origin'.
Branch 'pr-of-control-improvements' set up to track remote branch 'pr-of-control-improvements' from 'origin'.
Branch 'pr-rng_aid_hacks' set up to track remote branch 'pr-rng_aid_hacks' from 'origin'.
Branch 'pr-rng_aid_landed' set up to track remote branch 'pr-rng_aid_landed' from 'origin'.
Branch 'pr-tecs_throttle' set up to track remote branch 'pr-tecs_throttle' from 'origin'.
Branch 'pr-tecs_vz' set up to track remote branch 'pr-tecs_vz' from 'origin'.
Branch 'pr-terrain-fusion-cleanup' set up to track remote branch 'pr-terrain-fusion-cleanup' from 'origin'.
Branch 'pr-update_geo_lookup' set up to track remote branch 'pr-update_geo_lookup' from 'origin'.
Branch 'pr-wind_cov_init' set up to track remote branch 'pr-wind_cov_init' from 'origin'.
Branch 'refactor_unit_test' set up to track remote branch 'refactor_unit_test' from 'origin'.
Branch 'stable-coverage' set up to track remote branch 'stable-coverage' from 'origin'.
Branch 'synthetic_mag' set up to track remote branch 'synthetic_mag' from 'origin'.
Branch 'test-terrain-est-ground' set up to track remote branch 'test-terrain-est-ground' from 'origin'.
Branch 'variable_initializations' set up to track remote branch 'variable_initializations' from 'origin'.
Branch 'variadic_KHP_computation' set up to track remote branch 'variadic_KHP_computation' from 'origin'.

查看一下是否已经成功:

$ git branch
  Release_v1.10
  Release_v1.10.0
  Release_v1.11
  Release_v1.7.0
  accel-bias-divergence-debug
  coverity_scan
  dev-ekf-heading-reset-local
  ekfOptFlowFixes
  flow_interface
  gnss-yaw-noise
  gtest
* master
  nomag_init
  pr-alphafilter_minor
  pr-covariance_partial_double
  pr-ecl_ekf_defines
  pr-ecl_float_t
  pr-ekfBadImuHgtReset
  pr-ekfCovarianceFix
  pr-ekfSymPyDerivationConversion
  pr-ekfSymPyMagFusionAlt
  pr-ekfYawFailDetect
  pr-ekf_buffer_allocate
  pr-ekf_covariance_double_hacks
  pr-ekf_init_no_baro
  pr-ekf_initialise_filter_baro_mag
  pr-ekf_output_predictor_hacks
  pr-ekf_update_interval_parameter
  pr-ekf_vel_test_ratio
  pr-estimator_status_flags
  pr-ev_rng_aid
  pr-float_t
  pr-geo_globallocal
  pr-geo_split
  pr-globallocal_purge
  pr-gps-yaw-simplification
  pr-indoor_mag_hacks
  pr-l1-velocity-control
  pr-l1_updates
  pr-mag-fusion-restart
  pr-matrix_init
  pr-namespace
  pr-of-control-improvements
  pr-rng_aid_hacks
  pr-rng_aid_landed
  pr-tecs_throttle
  pr-tecs_vz
  pr-terrain-fusion-cleanup
  pr-update_geo_lookup
  pr-wind_cov_init
  refactor_unit_test
  stable-coverage
  synthetic_mag
  test-terrain-est-ground
  variable_initializations
  variadic_KHP_computation

3. 最后一步将所有分支更新到最新状态

git fetch --all && git pull --all
Fetching origin
Fetching origin
Already up to date.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小馬佩德罗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值