Last Updated: February 25, 2016
·
269
· ravi

Getting a single file from a Git remote repository

Say you want to get the contents of a single file from a Git remote repository without having to clone it. Here's a hack you can use with recent versions of Git:

git archive --remote=git@gitserver.example.com:myrepo master path/to/file1 | tar -xOf - > file1

The above gets the file at the specified path from <tt>master</tt>.