Search code examples
git

Browse and display files in a git repo without cloning


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

Solution

  • 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.