के आधार पर इस जवाब से apenwarr और इस टिप्पणी से Miral निम्नलिखित समाधान जो मुझे डिस्क स्थान का लगभग 94% बचाया जब क्लोनिंग के साथ आया था मैं linux Git स्थानीय स्तर पर भंडार है, जबकि केवल एक प्रलेखन उपनिर्देशिका चाहने:
$ cd linux
$ du -sh .git .
2.1G .git
894M .
$ du -sh
2.9G .
$ mkdir ../linux-sparse-test
$ cd ../linux-sparse-test
$ git init
Initialized empty Git repository in /…/linux-sparse-test/.git/
$ git config core.sparseCheckout true
$ git remote add origin ../linux
# Parameter "origin master" saves a tiny bit if there are other branches
$ git fetch --depth=1 origin master
remote: Enumerating objects: 65839, done.
remote: Counting objects: 100% (65839/65839), done.
remote: Compressing objects: 100% (61140/61140), done.
remote: Total 65839 (delta 6202), reused 22590 (delta 3703)
Receiving objects: 100% (65839/65839), 173.09 MiB | 10.05 MiB/s, done.
Resolving deltas: 100% (6202/6202), done.
From ../linux
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
$ echo "Documentation/hid/*" > .git/info/sparse-checkout
$ git checkout master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Already on 'master'
$ ls -l
total 4
drwxr-xr-x 3 abe abe 4096 May 3 14:12 Documentation/
$ du -sh .git .
181M .git
100K .
$ du -sh
182M .
इसलिए मैं 2.9GB से 182MB तक नीचे उतर गया जो पहले से ही शांत है।
हालाँकि मुझे इसके साथ काम करने के लिए नहीं मिला था git clone --depth 1 --no-checkout --filter=blob:none file:///…/linux linux-sparse-test
( तब यहाँ संकेत दिया गया था ) तब लापता फ़ाइलों को हटा दिया गया था। तो अगर किसी को भी जानता है के बराबर git clone --filter=blob:none
के लिए git fetch
, हम शायद कुछ और मेगाबाइट बचा सकता है। (मैन पेज को पढ़ना git-rev-list
भी संकेत देता है कि कुछ ऐसा है --filter=sparse:path=…
, लेकिन मुझे वह काम नहीं मिला।
(सभी ने डेबियन बस्टर से 2.20.1 git के साथ प्रयास किया।)