Executing git commands on a bare repository

一曲冷凌霜 提交于 2019-12-04 22:14:25

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/11377827/executing-git-commands-on-a-bare-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!