2020年3月18日 星期三

讓 git clone 只下載指定的 branch

在使用 git clone 目標資源時,有時後會只需要下載某個特定的分支,而不是全部的分支來避免 .git 資料夾放了太多不必要的資料。


查了一下資料 git 在版本 1.7.10 後提供了 --single-branch 的選項可滿足該需求,如下

$ git clone --single-branch --branch <branchname> <remote-repo>

Example:

$ git clone --single-branch --branch dev https://github.com/linmasaki/Kendo.DynamicLinqCore.git




參考資料

[Stack Overflow] How do I clone a single branch in Git

訪客統計

103325