8

On my server, I host some bare git repositories that I'm working on. I'd like to display some basic statistics about each repository on my website; for now, let's just say I want to do simple stuff like listing all the files in the repository. On a non-bare git repository, this can be done with

git ls-files

but for bare repositories this (and most other git commands) don't work. I'm sure there's probably a simple way of doing this particular command, but I'll probably want to show some complicated/project-specific stats for different repositories, so I'm really asking if there's a way to execute any/all git commands on a bare repository without have to make a temporary clone or something convoluted like that. I suspect there's some command parameter I need to set, but I haven't been able to figure out which one yet.

Jesper Rønn-Jensen
  • 106,591
  • 44
  • 118
  • 155
Josh Buell
  • 606
  • 5
  • 12
  • I don't think gitweb does everything I might possibly want to track; I expect I'll want some rather specific stats in the future, like "show all commits that were done by user X whose message contains the string Y that were before date Z" so I'll probably have to write the scripts to handle that myself, which require commands that bare repos don't do. – Josh Buell Jul 07 '12 at 19:39
  • Another command I had trouble getting to work was git blame, but [this](http://stackoverflow.com/questions/4169556/how-to-git-blame-on-the-remote-side-repository) SO question answered it. – Josh Buell Jul 08 '12 at 19:31

1 Answers1

13

You can run this one:

git ls-tree -r HEAD --name-only

Obviously you have to specify a branch or reference, because there is no working tree or index in a bare repository.

I don't know for other commands but you can actually do most of them in a bare repository, but those that require a working tree.

Antoine Pelisse
  • 12,871
  • 4
  • 34
  • 34