

mv /where/it/is/right/now/* /where/I/want/it/ git folder is hidden in most graphical file explorers, so be sure to show hidden files. See udondan's answer below for information on how to combine shallow clone and sparse checkout.Īs of git 2.25.0 (Jan 2020) an experimental sparse-checkout command is added in git: git sparse-checkout init But if you don't need the history of the repository, you can at least save on bandwidth by creating a shallow clone. At the moment it is not possible to clone only a single directory. Note that this will still download the whole repository from the server – only the checkout is reduced in size. Usage: git_sparse_clone "" "./local/location" "/bin" You might want to have a look at the extended tutorial and you should probably read the official documentation for sparse checkout and read-tree.Īs a function: function git_sparse_clone() ( You will now have files "checked out" for some/dir and another/sub/tree on your file system (with those paths still), and no other paths present. Last but not least, update your empty repo with the state from the remote: git pull origin master git/info/sparse-checkoutĮcho "another/sub/tree" >.

git/info/sparse-checkout, eg: echo "some/dir/" >. Now you need to define which files/folders you want to actually check out. Then do: git config core.sparseCheckout true This creates an empty repository with your remote, and fetches all objects but doesn't check them out. The steps to do a sparse clone are as follows: mkdir What you are trying to do is called a sparse checkout, and that feature was added in git 1.7.0 (Feb.
