git download only some files matching pattern

68 Views Asked by At

What is the easiest way to clone only files matching a certain pattern, e.g. Java files, from a repository? I can do a git clone followed by a git checkout with some pattern, but this will result in downloading unnecessary files, potentially a large number of them, which I want to avoid.

Context: I am building a tool to download code from a large number of repositories for a Machine Learning model training. I plan to download thousands or tens of thousands of repositories, so I want to make sure I only download the files I need, first, to speed up the process and, second, to reduce the likelihood of throttling from GitHub.

Thanks, Rafid

0

There are 0 best solutions below