There's more...

The archive command can also be used to create an archive for a subdirectory of the repository. We can use this on the doc branch of the repository to ZIP the content of the Documentation folder:

$ git archive --prefix=docs/ -o docs.zip origin/doc:Documentation

Again, we can list the contents of the ZIP file and the Documentation tree at origin/doc, as follows:

$ unzip -l docs.zip
  Archive:  docs.zip
   Length     Date   Time    Name
  --------    ----   ----    ----
        0  04-13-14 21:14   docs/
       99  04-13-14 21:14   docs/README.md
      152  04-13-14 21:14   docs/build.md
  --------                   -------
      251                   3 files
  $ git ls-tree -l origin/doc:Documentation
  100644 blob b65b4fc78c0e39b3ff8ea549b7430654d413159f 99  README.md
  100644 blob f91777f3e600db73c3ee7b05ea1b7d42efde8881 ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.