# Shallow downloads of git repos via FetchContent

**URL:** https://discourse.cmake.org/t/shallow-downloads-of-git-repos-via-fetchcontent/10220
**Category:** Development
**Created:** [February 28, 2024, 3:17pm UTC](https://discourse.cmake.org/t/shallow-downloads-of-git-repos-via-fetchcontent/10220 "2024-02-28T15:17:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![LarryOates](https://discourse.cmake.org/user_avatar/discourse.cmake.org/larryoates/32/3654_2.png) [@LarryOates](https://discourse.cmake.org/u/LarryOates)
#### Post date: [February 28, 2024, 3:17pm UTC](https://discourse.cmake.org/t/shallow-downloads-of-git-repos-via-fetchcontent/10220/1 "2024-02-28T15:17:02Z")

</div>

I am using [CPM](https://github.com/cpm-cmake/CPM.cmake) to download dependency of my project. The dependencies is a large repo and a tag has been made which removes a lot of unneeded parts of the repo. This was done so that when the project is being configured, it takes 30 secs instead of minutes to fetch what it needs.

I used GIT\_SHALLOW when adding the package and have confirmed that --depth 1 gets through to the git clone command (as well as --no-single-branch which I think might be a mistake for this purpose?).  
The --branch option isn’t present however which is causing the whole repo to be downloaded. CMake seems to download the whole repo then switch to the branch you request even with GIT\_SHALLOW defined.

Is there any work around for this? Am I missing something?  
Cheers,  
Larry

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 29, 2024, 4:47am UTC](https://discourse.cmake.org/t/shallow-downloads-of-git-repos-via-fetchcontent/10220/2 "2024-02-29T04:47:02Z")

</div>

This topic has a fairly long history, which you can find in the CMake issue tracker here: [https://gitlab.kitware.com/cmake/cmake/-/issues/17770](https://gitlab.kitware.com/cmake/cmake/-/issues/17770)
