Monday, December 22, 2014

Retrieve a single file from a git repo.

The answer to this was more difficult to find than it should have been. The best answer is on stackoverflow here.

In short, use the git archive command:

git archive --remote=git@github.com:foo/bar.git --prefix=path/to/ HEAD:path/to/ |  tar xvf -


  • For this to work the owner of the git server needs to have enabled upload-archive (git config daemon.uploadarch true)
  • You need tar -xvf because the output is in tar form

No comments:

Post a Comment