采用-b指定tag,--depth=1指定只拉取最后一个版本的代码,日志如下
yeqiang@yeqiang-MS-7B23:~/Downloads/src$ git clone --depth=1 -b 7cbf1a2 https://github.com/llvm/llvm-project
正克隆到 'llvm-project'...
warning: 不能发现要克隆的远程分支 7cbf1a2。
fatal: 远程分支 7cbf1a2 在上游 origin 未发现
yeqiang@yeqiang-MS-7B23:~/Downloads/src$ git clone --depth=1 -b llvmorg-16.0.6 https://github.com/llvm/llvm-project
正克隆到 'llvm-project'...
remote: Enumerating objects: 132947, done.
remote: Counting objects: 100% (132947/132947), done.
remote: Compressing objects: 100% (107072/107072), done.
remote: Total 132947 (delta 28313), reused 67422 (delta 21784), pack-reused 0
接收对象中: 100% (132947/132947), 187.34 MiB | 961.00 KiB/s, 完成.
处理 delta 中: 100% (28313/28313), 完成.
注意:正在切换到 '7cbf1a2591520c2491aa35339f227775f4d3adf6'。您正处于分离头指针状态。您可以查看、做试验性的修改及提交,并且您可以在切换
回一个分支时,丢弃在此状态下所做的提交而不对分支造成影响。如果您想要通过创建分支来保留在此状态下所做的提交,您可以通过在 switch 命令
中添加参数 -c 来实现(现在或稍后)。例如:git switch -c <新分支名>或者撤销此操作:git switch -通过将配置变量 advice.detachedHead 设置为 false 来关闭此建议正在更新文件: 100% (126307/126307), 完成.
可以看到拉取下来的代码体积不大。
git log验证,只有一个记录
yeqiang@yeqiang-MS-7B23:~/Downloads/src/llvm-project$ git log
commit 7cbf1a2591520c2491aa35339f227775f4d3adf6 (grafted, HEAD, tag: llvmorg-16.0.6)
Author: Sam Clegg <sbc@chromium.org>
Date: Tue Apr 4 10:24:40 2023 -0700[lld][WebAssembly] Fix stub library parsing with windows line endingsAlso, fix checking of first line in ::parse. We can't use the::getLines helper here since that already does comment strippinginternally.Differential Revision: https://reviews.llvm.org/D147548(cherry picked from commit d9d840cdaf51a9795930750d1b91d614a3849137)
git branch及git tag
yeqiang@yeqiang-MS-7B23:~/Downloads/src/llvm-project$ git branch
* (非分支)
yeqiang@yeqiang-MS-7B23:~/Downloads/src/llvm-project$ git tag
llvmorg-16.0.6