Browse and display files in a git repo without cloning

0 votes
asked Jul 24, 2009 by ianalis

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

5 Answers

0 votes
answered Jul 24, 2009 by jkp

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.

0 votes
answered Jul 7, 2011 by jerome-baum

Take a look at for info on how to do this over some transport protocols. Note this won't work for standard git over SSH.

For git over SSH, an up-to-date server-side git should allow you to git-archive directly from the remote, which you could then e.g. pipe to "tar t" to get a list of all files in a given commit.

0 votes
answered Jul 19, 2013 by anne-van-rossum

This is probably considered dirty by some, but a very practical solution in case of github repositories is just to make a script, e.g. "git-ls":

remote_url=${1:? "$0 requires URL as argument"}
curl -s $remote_url | grep js-directory-link | sed "s/.* title=\"\(.*\)\".*/\1/"

Make it executable and reachable of course: chmod a+x git-ls; sudo cp git-ls /usr/local/bin. Now, you just run it as you wish:


Also know that there is a git instaweb utility for your local files. To have the ability to show files and have a server like that does in my opinion not destroy any of the inherent decentralized characteristics of git.

0 votes
answered Jul 12, 2015 by anurag-kanungo

Not the exact, but a way around.

Use GitHub Developer API

  1. Opening this will get you the recent commits.

    You can get the specific commit details by attaching the commit hash in the end of above url.

  2. All the files ( You need sha for the main tree)

I hope this may help.

0 votes
answered Jul 4, 2016 by fela

GitHub is svn compatible so you can use svn ls

svn ls

BitBucket supports git archive so you can download tar archive and list archived files. It is not very efficient but works:

git archive HEAD directory | tar -t
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter