Git equivalent of `svn cat` with remote repository
Here is a hack you can use with recent versions of Git to get a single file from a remote repo (to which you have Git access) without cloning the repo:
git archive --remote=git@gitserver.example.com:myrepo master path/to/file1 | tar -xOf - > file1
The above gets the file from master
. Modify to your needs.
If your motivation is to minimize the amount of data downloaded and/or stored on your local disk, you could try the below commands.
git clone --depth=1 --bare REPOcd REPO.gitgit show HEAD:PATH/TO/FILE
--depth=1
means you'll download only the most recent revision, not any history. --bare
means you will download the remote repository, but won't actually create any working tree, saving space on your local disk.
Note that if you're interested in a version of the file other than the most recent, the above commands won't work, since they do not download any history.