If you are not familiar with Git, check out our getting started article. These examples are based on Linux.
The git archive command can be used to create an archive, such as zip, gzip, or bzip2 archive. In this example, a gzip archive named example.tar.gz is created of the master branch of the foo.git repository.
git archive --remote ssh://git@example.com/path/to/foo.git master --format tar.gz --output /path/to/example.tar.gz
Or like this.
git archive --remote ssh://git@example.com/path/to/foo.git master | gzip > example.tar.gz
Let's say the foo.git repository contains two directories, "foo" and "bar". Here is how you could create an archive of only the "bar" directory.
git archive --remote ssh://git@example.com/path/to/foo.git master bar/ | gzip > example.tar.gz