Android git clone 文件大,depth=1了解

最近比较清闲哈~
检查检查Android项目完成情况吧,clone项目漫长的等待,项目文件小2G -_-!!!
对于临时clone项目这是个灾难呀

那么问题来了,如何clone一个轻量级的呢?

查到一个命令 --depth

https://git-scm.com/docs/git-clone
–depth < depth >
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.

创建一个浅克隆,其历史记录被截断到指定的提交数量。没有给出单分支,会获取所有分支附近的历史记录。如果希望浅克隆子模块,还需要传递–浅子模块。

我们来终端实践一下
$git clone giturl --depth=1
depth用于指定克隆深度,为1表示只克隆最近一次commit.

MBP:Desktop mbp$ git clone https://git.dev.tencent.com/username/Android.git --depth=1
Cloning into 'Android'...
Username for 'https://git.dev.tencent.com': username
Password for 'https://[email protected]': 
remote: Enumerating objects: 3283, done.
remote: Counting objects: 100% (3283/3283), done.
remote: Compressing objects: 100% (2581/2581), done.
remote: Total 3283 (delta 1203), reused 2183 (delta 513)
Receiving objects: 100% (3283/3283), 198.51 MiB | 761.00 KiB/s, done.
Resolving deltas: 100% (1203/1203), done.
Checking out files: 100% (2980/2980), done.
MBP:Desktop mbp$ 

此时项目文件大小只有几百兆。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章