裸仓库中的 git ls-files
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25906192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git ls-files in bare repository
提问by Jesper R?nn-Jensen
I want to access a bare git repository, and I want to list all files in the repository.
我想访问一个裸 git 存储库,并且我想列出存储库中的所有文件。
On a normal git repository I can easily do that by running git ls-files
.
在普通的 git 存储库中,我可以通过运行git ls-files
.
Example output:
示例输出:
$ git ls-files
README.md
file1.js
file2.js
file3.js
folder1/file4.js
folder2/file5.js
In a bare git repository this fails silently. It just doesn't return any files (but exits successfully):
在裸 git 存储库中,这会以静默方式失败。它只是不返回任何文件(但成功退出):
$ cd my-bare-repository
$ git ls-files #returns nothing
$ echo $? #print exit code from previous command
$ 0
Now I am aware that I have to provide a meaningful branch or master to display. But how can I actually get this list of the files that I know are in my repository?
现在我知道我必须提供一个有意义的分支或主节点来显示。但是我如何才能真正获得我知道在我的存储库中的文件列表?
回答by VonC
You can try the other command which list files:
您可以尝试列出文件的其他命令:
git ls-tree --full-tree -r HEAD
According to this comment, the command git ls-treeworks in bare repo.
根据这个评论,命令git ls-tree在裸仓库中工作。