Take the 2-minute tour ×

Is there an easy way to grab files or directory listings from a remote bare git repository (preferably over SSH or git:// protocols)?


I am trying to migrate from SVN to Git and we have some processes that download files directly from the Subversion repository over DAV deep within the tree (wget http://server/svn/branches/production/dir1/file). I need to replicate this behavior in git, but I don't think it's possible without checking out (& keeping updated) a remote working directory with apache pointing at it.

I see a git ls-remote git@server:repo.git but I don't think you can go deeper into actual files.

I realize that doing this isn't the best way and I am also open to other ideas about how to handle processes needing specific files out of the tree.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I think the only way to do what you want is to maintain an updated git tree locally (though I could be wrong, and someone will correct me if I am).

What you're doing with SVN is really a hack -- If you were using svnserve instead of SVN-over-HTTP/DAV I don't believe you'd be able to do what you're doing. It just happens that the confluence of software you're using for SVN makes this possible.
The closest analog I can come up with would be an automatically-updating git repository in a directory accessible over HTTP, and that's a pretty hideous solution.

share|improve this answer
Well then there's another isssue of the branches. Git doesn't switch branches based on filesystem path. So then I'd have to potentially have n-number of workdirs, 1 for each branch, that doesn't scale well at all. –  AndrewF Oct 25 '10 at 20:13
@AndrewF - Or a PHP/Perl/Whatever script that locks the directory, checks out the branch & returns the file -- This doesn't scale well either though. How did this functionality evolve in your environment? Maybe there's a better way... –  voretaq7 Oct 26 '10 at 13:29
It's for our Configuration management system that our package manager uses and pulls versioned packages out of the repository. I think we should be separating packages from our configuration management. That's probably the best course of action. –  AndrewF Oct 26 '10 at 16:38
I definitely wouldn't use version control systems for storing binary packages (though storing/versioning the code the packages are generated from is obviously smart). Configuration/Deployment management is a whole can of worms unto itself though :-) –  voretaq7 Oct 26 '10 at 16:57
add comment

Have you tried git show (git show hash:filename)? That definitely works for a local repo and may work remotely.

share|improve this answer
Yeah I tried that, it doesn't seem to work on a remote repository. I think voretaq7 is correct though - I should totally re-think how this is done. –  AndrewF Oct 25 '10 at 20:12
add comment

Your Answer


