git从远程仓库gitLab上拉取指定分支到本地仓库
·
git从远程仓库gitLab上拉取指定分支到本地仓库并且pull的时候也是从分支pull
git checkout -b vio_stm32_can_image_1 origin/vio_stm32_can_image
这个命令就好使,但是有一点要注意,在web端建立新分支后,本地的master要pull一下,不然该命令找不到远程的新分支。
另外还可以使用另一个命令(gitbash 上也会提示)
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/ vio_stm32_can_image
所以我就使用了该命令:
git branch --set-upstream-to=origin/vio_stm32_can_image vio_stm32_can_image
这样本地的分支就跟远程的分支对应起来了,当然,本地分支名称可以不用跟远程分支名称一样
执行git remote show origin
git remote show origin
- remote origin
Fetch URL: git@gitlab.momenta.works:zhoulei/vio_stm32f405_project.git
Push URL: git@gitlab.momenta.works:zhoulei/vio_stm32f405_project.git
HEAD branch: master
Remote branches:
master tracked
vio_mcu_modify_led tracked
vio_stm32_can_image tracked
vio_stm32_haval tracked
vio_stm32f405_can_gps_image tracked
vio_stm32f405_imu_imx6 tracked
Local branches configured for ‘git pull’:
master merges with remote master
vio_stm32_can_image merges with remote vio_stm32_can_image
vio_stm32_can_image_1 merges with remote vio_stm32_can_image
vio_stm32f405_can_gps_image merges with remote vio_stm32f405_can_gps_image
vio_stm32f405_imu_imx6 merges with remote vio_stm32f405_imu_imx6
Local refs configured for ‘git push’:
master pushes to master (up to date)
vio_stm32_can_image pushes to vio_stm32_can_image (local out of date)
vio_stm32f405_can_gps_image pushes to vio_stm32f405_can_gps_image (up to date)
vio_stm32f405_imu_imx6 pushes to vio_stm32f405_imu_imx6 (fast-forwardable)
通过上述命令结果发现,本地分支的pull和push都和远程分支对应起来了
其实通过另一个命令也可以看到本地分支跟远程分支是否对应起来,但是应该不知道是不是pull和push都对应起来
$ git branch -av
master ea184b2 Merge branch ‘vio_stm32f405_imu_imx6’ into ‘master’
vio_stm32_can_image c2b91c0 Module:GPS接到Soc上,使用Soc授时
- vio_stm32_can_image_1 deaebeb Module:
vio_stm32f405_imu_imx6 ea184b2 [ahead 1] Merge branch ‘vio_stm32f405_imu_imx6’ into ‘master’
remotes/origin/HEAD -> origin/master
remotes/origin/master ea184b2 Merge branch ‘vio_stm32f405_imu_imx6’ into ‘master’
remotes/origin/vio_mcu_modify_led 0affcb3 Module:mapsh1
remotes/origin/vio_stm32_can_image deaebeb Module:
remotes/origin/vio_stm32_haval 95dfc0c 新建分支,哈佛车使用
remotes/origin/vio_stm32f405_can_gps_image 04fa9ec Module:Add sensor(GPS/IMAGE/CAN) ID
remotes/origin/vio_stm32f405_imu_imx6 37b7d52 modify the imu len
下面这个命令也可以直接创建一个本地分支来对应远程分支:
git checkout -b vio_stm32_can_image_1 origin/vio_stm32_can_image
更多推荐


所有评论(0)