How do I clone, fetch or sparse checkout a single file or directory or a list of files or directories from a git repository avoiding downloading the entire history or at least keeping history download at minimum?
For the benefit of people landing here, these are references to other similar questions:
- How do I clone a subdirectory only of a Git repository?
- How to sparsely checkout only one single file from a git repository?
- Is it possible to do a sparse checkout without checking out the whole repository first?
These similar questions were asked long ago and git evolved ever since, which ended up causing a flood of different answers, some better, some worse, depending on the version of git being considered. The trouble is that not a single answer from these aforementioned questions attend all requirements from all these questions combined, which means that you have to read all answers and compile in your head your own answer which eventually attend all requirements.
This question here expands on previous questions mentioned, imposing more flexible and stringent requirements than all other questions combined. So, once again:
How do I clone, fetch or sparse checkout a single file or directory or a list of files or directories from a git repository avoiding downloading the entire history or at least keeping history download at minimum?
git clone --depth
is mentioned as well asgit clone --filter
. The second search link works for me. – Terbecki