在裸仓库上执行git命令 [英] Executing git commands on a bare repository
问题描述
在我的服务器上,我托管了一些我正在开发的裸机git存储库。我想在我的网站上显示关于每个存储库的一些基本统计信息;现在,让我们说我想做简单的事情,比如列出存储库中的所有文件。在一个非纯粹的git仓库中,可以使用
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
但是对于裸存储库,这个(和大多数其他git命令)不起作用。我确信可能有一个简单的方法来执行这个特定的命令,但我可能想要为不同的存储库显示一些复杂的/特定于项目的统计信息,所以我真的问是否有办法执行任何/所有的git命令放在裸仓库上,而不必做一个临时的克隆或类似的东西。我怀疑有一些命令参数需要设置,但我还没有弄清楚哪一个命令参数。
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.
推荐答案
您可以运行这一个:
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.
这篇关于在裸仓库上执行git命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!