Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing git commands on a bare repository

Tags:

git

git-bare

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.

like image 992
Josh Buell Avatar asked Jul 07 '12 19:07

Josh Buell


1 Answers

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.

like image 60
Antoine Pelisse Avatar answered Sep 22 '22 19:09

Antoine Pelisse