无需克隆即可浏览和显示 git 存储库中的文件 [英] Browse and display files in a git repo without cloning
问题描述
有没有办法在不先克隆的情况下浏览和显示 git 存储库中的文件?我可以使用以下命令在 svn 中执行这些操作:
<前>svn ls/path/to/reposvn cat/path/to/repo/file-in-repo我应该可以使用 git show 但这样做:
<前>git show/path/to/repogit show HEAD:/path/to/repo结果
<前>致命:不是 git 存储库你想要的命令是 git ls-remote
它允许您获取有关远程存储库的一些信息,但您无法显示历史记录或列表目录或该级别的任何内容: 本质上,它只能让您在非常高的层次上看到远程对象(例如,您可以看到当前的 HEAD 和标签).
做你想做的唯一真正的方法(如果我理解正确的话)是使用 ssh 运行远程命令并返回结果,例如:
ssh me@otherhost "cd repo && git log -n 10"
如果他们可以添加它,您想要的将是可爱的功能,但从我读到的内容来看,这并不容易,因为获取历史记录等需要大量信息才能在 git 本地化,此时您可能已经完成了一个 git fetch.
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
I can supposedly use git show but doing:
git show /path/to/repo git show HEAD:/path/to/repo
result to
fatal: Not a git repository
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).
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"
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屋!