Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a list of files / file tree on remote git repo

Tags:

git

github

I did a clone of a remote without a checkout:

git clone -n [email protected]:RobKohr/awesome-repo.git

and can clone an individual file:

git checkout HEAD README.md

but I would like to get a list of all the files in the repo without fetching the files themselves.

Is there a way to do this?

This is for a rather large private github repo that I only have ssh deploy access to (not web access), and I don't want to check out the whole thing. I want to get the file list so I can pick and choose.

like image 782
RobKohr Avatar asked Nov 01 '25 03:11

RobKohr


1 Answers

There are only two ways to do that — either using clone or via Github API. If you don't have access to the API clone is the only solution.

You can speed things up a bit using shallow clone. Do not clone the entire repository — clone only the last commit into a bare repository and run git ls-tree:

git clone --bare --depth=1 [email protected]:RobKohr/awesome-repo.git
cd awesome-repo.git
git ls-tree --name-only -r HEAD
like image 153
phd Avatar answered Nov 02 '25 23:11

phd