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