'Any idea on how this git fetch can be optimized?
git fetch origin %Branch_SourcePath% --depth 100 --no-tags --progress --verbose --recurse-submodules 2>&1
The command above takes about 1 hour to complete which is too long. Using --depth 1 completes the fetch in under 4 minutes however I do need the commit information for at least the last 100 commits.
Majority of the time is spent on download/receiving objects.
Receiving objects: 99% (764574/764593), 25.39 GiB | 13.32 MiB/s
Solution 1:[1]
option #1: sparse checkout
If you only need a subtree of the original directory tree, one thing you can try is the so-called sparse checkout.
For example, lets say we are interested only in /foo subdirectory.
git clone --sparse --depth 10 --branch master https://github.com/Acme/helloworld
Change directory into the newly-cloned repository and enable sparse-checkout mechanism (to fetch parts of the subtree in steps of increasing depth):
cd helloworld
git sparse-checkout init --cone
Checkout a subtree, say at /foo:
git sparse-checkout set foo
option #2: filtering BLOBs
Another thing you can try is to filter BLOB objects (--filter blob:none in git-clone command).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
