0

I want to get a list of file names in a directory on my master branch without cloning the repository.

I've looked at ls-file and ls-tree but they only seem to work locally. My current solution is to use git-archive and split the content using pattern matching.

My current regex for a file path is ^\/?([A-z0-9-_+]+\/)*([A-z0-9-_+]+(\.[A-z0-9]+)?)$

"over the wire" I want to receive something like

file_1.file
file_2.file
...
  • https://stackoverflow.com/questions/1178389/browse-and-display-files-in-a-git-repo-without-cloning – rprakash Sep 12 '19 at 18:11
  • @rprakash From that answer "... but you **cant** show history or list directories or anything of that level ..." \n If you can demonstrate that it **is** possible could you please provide an example to get the files in `/dir/path` – Nolan Dougherty Sep 12 '19 at 20:44
  • you can not do it directly. if you can ssh to the remote site, do it as in the answer above. Otherwise to fetch first and check its contents with ls-tree. – Serge Sep 13 '19 at 00:30
  • @NolanDougherty Sometimes "you cannot" is the answer and you have to accept that. `git` cannot list files in the remote. So you have to get the files locally either with `clone` or `archive`. If you have access to the remote repo outside of `git` (ssh or http(s)) you can try list files with that access. For example, Github and Gitlab provide API-over-HTTP. But that's not `git`. – phd Sep 13 '19 at 10:49
  • Thanks for the replies guys. I'll have to work around this I guess. – Nolan Dougherty Sep 13 '19 at 17:46

0 Answers0