浏览并显示git仓库中的文件而无需克隆 [英] Browse and display files in a git repo without cloning

查看:134
本文介绍了浏览并显示git仓库中的文件而无需克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在git仓库中浏览和显示文件而无需先克隆它?我可以使用以下命令在svn中执行这些操作:

Is there a way to browse and display files in a git repo without cloning it first? I can do those in svn using the commands:


svn ls /path/to/repo 
svn cat /path/to/repo/file-in-repo

我可以使用git show,但是这样做:

I can supposedly use git show but doing:


git show /path/to/repo
git show HEAD:/path/to/repo

结果为


fatal: Not a git repository


推荐答案

您需要的命令是 git ls-remote ,它允许你获得关于远程存储库的一些信息,但你不能显示历史或列表目录或任何该级别的数据:本质上它只允许您以非常高的级别查看远程对象(例如,您可以看到当前的HEAD和标记)。

The command you want is git ls-remote which allows you to get some information about remote repositories, but you cant show history or list directories or anything of that level: essentially it only lets you see the remote objects at a very high-level (you can see the current HEADs and tags for example).

做你想做的事情(如果我理解正确的话)唯一真正的方法是使用ssh运行远程命令并返回结果例如:

The only real way to do what you want (if I understand correctly) would be to use ssh to run a remote command and return the results, for example:

ssh me@otherhost "cd repo && git log -n 10"

如果可以添加的话,我读过的东西并不是很容易,因为获得历史记录等需要大量的信息才能成为本地的git,在这一点上,你可能已经完成了git fetch。

What you want would be lovely functionality if they could add it, but from what I read it's not very easy since getting history etc needs a lot of information to be local to git, and at that point you may as well have done a git fetch.

这篇关于浏览并显示git仓库中的文件而无需克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆