来自git-clone(1)手册页
--branch
也可以在结果存储库中的提交处获取标记并分离HEAD.
我试过了
git clone --branch
但它不起作用.它返回:
warning: Remote branch 2.13.0 not found in upstream origin, using HEAD instead
如何使用此参数?
git clone --branch <tag_name> <repo_url>
git 1.7.9.5不支持此命令.
我使用git 1.8.3.5,它的工作原理
使用--single-branch
选项仅克隆导致标记提示的历史记录.这样就可以节省大量不必要的代码.
git clone <repo_url> --branch <tag_name> --single-branch
git clone -b 13.1rc1-Gotham --depth 1 https://github.com/xbmc/xbmc.git Cloning into 'xbmc'... remote: Counting objects: 17977, done. remote: Compressing objects: 100% (13473/13473), done. Receiving objects: 36% (6554/17977), 19.21 MiB | 469 KiB/s
将比以下更快:
git clone https://github.com/xbmc/xbmc.git Cloning into 'xbmc'... remote: Reusing existing pack: 281705, done. remote: Counting objects: 533, done. remote: Compressing objects: 100% (177/177), done. Receiving objects: 14% (40643/282238), 55.46 MiB | 578 KiB/s
要么
git clone -b 13.1rc1-Gotham https://github.com/xbmc/xbmc.git Cloning into 'xbmc'... remote: Reusing existing pack: 281705, done. remote: Counting objects: 533, done. remote: Compressing objects: 100% (177/177), done. Receiving objects: 12% (34441/282238), 20.25 MiB | 461 KiB/s