tags:

views:

803

answers:

1

Is there any way to get the contents of a single file from a remote git repository? "git archive" looks promising, except that GitHub has it explicitly disabled.

The following StackOverflow question generally had the right idea: http://stackoverflow.com/questions/1125476/git-retrieve-a-single-file-from-a-repository

In our situation, we're basically looking to do a "git show " except that we'd like to perform that against git://github.com/SomeUser/SomeRepository.

Right now we have a script that simply clones the repository locally and executes "git show" which does the job. We're looking for a way around the clone. Simplicity is ideal in this situation rather than availability of the remote repository.

+2  A: 

What about parsing the github url? It looks like you can get the raw contents of a file (using curl, wget etc...) via something like:

http://github.com/SomeUser/SomeRepository/raw/CommitId/Path/To/File
Karl Voigtland
Where `CommitId` can be name of branch (but I think currently it cannot be just `HEAD`). Also GitHub has an API.
Jakub Narębski
Yes, this would work--but only for Github and other providers that provide the source via HTTP. I was hoping for a more generic solution that just used git.What we ended up doing was cloning the repository locally and then piping the output of "git show" to a file.
Jonathan Oliver