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$ 

此時項目文件大小隻有幾百兆。

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