1

What is the shortest, simplest way (preferably one line command) to download a single subdirectory from a Git repository? The goal is for an end-user (i.e. not a programmer) to get a copy of a subdirectory as easily as possible.


This is related to, but not a clone of "How do I clone a subdirectory only of a Git repository?", as that question concerns itself with cloning the directory and still being able to use the directory within Git. Whereas I just want the user to get a local copy, git history, and other information need not be downloaded in my case. Its ok if it is, its just not required.

Community
  • 1
  • 1
  • Do you really mean github in particular, as opposed to git in general? – bmargulies Apr 13 '15 at 23:59
  • I'm using github, so a github answer would be helpful, but I presume there are few differences between a github repo and a regular git repo. –  Apr 14 '15 at 00:00

2 Answers2

0

Note that git, intrinsically, has nothing to do with downloads. A git repo just sits there on your disk, except for git daemon, which does will not help you make downloads available to ordinary users.

As far as I know, there is no easy way to do what you want. github in particular supports various ways to download flat files, but I do not believe that it provides a URL that packages up a directory; all it can do is 'release' tarballs. Subdirectories are especially problematic: you need a web service that responds with a ZIP or tar file, and the user will have to interact with the browser to get it unpacked.

I did find a PHP solution that you could layer atop a file system that happened to be populated from a git repo.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
0

If the subdirectory was a submodule, it would be relatively easy; just git clone that. But you'd still get the whole repo, not the working tree. If you want just the working tree there is nothing git can do for you.

So you'd have to do things differently.If it is on a machine that you have control over you could make the directory in question accessible via e.g;

  • rcp
  • rsync
  • ftp (as a zip or tar file)
Roland Smith
  • 42,427
  • 3
  • 64
  • 94