git command tips: clone/fetch remote single branch

1. clone single branch

 git clone    -o  $newremote_name    --single-branch  -b $stable_branch_name -n   git@github.com:YourProject/$git_prj.git

2. clone only one tag commit ID

git clone -b   tagname   --depth 1    remote_git_url

Example/LTS kernel

git clone -b   v4.19   --depth 1    https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

This is also OK for repo init

Example 

repo init --depth=1  -u https://android.googlesource.com/platform/manifest -b android-5.1.0_r5 

 

Example/Git source  
[lake@localhost git]$ git clone   -b  v2.30.0    --depth  1    https://github.com/git/git
[lake@localhost git]$ git branch   -av
* (no branch) 71ca53e Git 2.30

 

 

3. Remote add sing branch 

git remote add  -t   remotebranchname  remotename  gitURLname 

example 

git remote add  -t   stable-4.4-rk3399-linux     Firefly    https://github.com/FireflyTeam/kernel.git       
     

 
lake@localhost:~/local/lake/friendlyarm-3399/kernel$ git branch -av
* (no branch)                                 fc81430 media: i2c: tc35874x: moveinitcall
  remotes/m/master                            -> origin/nanopi4-linux-v4.4.y
  remotes/origin/release-3.10                 6c04d00 isp11: rockchip: adjust thfor isp clk
  remotes/origin/release-3.14                 a5bb31b iommu/rockchip: add compatr vpu_mmu
  remotes/origin/release-4.4                  3dd9af3 arm64: dts: rockchip: px30default timing
 
lake@localhost:~/local/lake/friendlyarm-3399/kernel$ git remote add  -t   stable-4.4-rk3399-linux     Firefly    https://github.com/FireflyTeam/kernel.git       

lake@localhost:~/local/lake/friendlyarm-3399/kernel$ git remote  -v
Firefly https://github.com/FireflyTeam/kernel.git (fetch)
Firefly https://github.com/FireflyTeam/kernel.git (push)
origin  https://github.com/friendlyarm/kernel-rockchip (fetch)
origin  https://github.com/friendlyarm/kernel-rockchip (push)  
lake@localhost:~/local/lake/friendlyarm-3399/kernel$ git fetch  Firefly
remote: Enumerating objects: 531, done.
remote: Counting objects: 100% (531/531), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 890 (delta 523), reused 521 (delta 521), pack-reused 359
Receiving objects: 100% (890/890), 683.38 KiB | 292.00 KiB/s, done.
Resolving deltas: 100% (765/765), completed with 145 local objects.
From https://github.com/FireflyTeam/kernel
 * [new branch]      stable-4.4-rk3399-linux -> Firefly/stable-4.4-rk3399-linux
lake@localhost:~/local/lake/friendlyarm-3399/kernel$ git branch -av
* nanopi4-linux-v4.4.y                        fc81430 media: i2c: tc35874x: move init to late_initcall
  remotes/Firefly/stable-4.4-rk3399-linux     eb65ab2 arm64: dts: add spiwkxxx reset-gpio  =======>  New remote branch 
  remotes/m/master                            -> origin/nanopi4-linux-v4.4.y
  remotes/origin/release-3.10                 6c04d00 isp11: rockchip: adjust the calculation for isp clk
  remotes/origin/release-3.14                 a5bb31b iommu/rockchip: add compatible string for vpu_mmu
  remotes/origin/release-4.4                  3dd9af3 arm64: dts: rockchip: px30: modify dram default timing
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值