2

I know how to download a file from a gitlab repo and I didn't find anything on downloading a directory. I need to download only a directory.

Ashwani
  • 1,340
  • 1
  • 16
  • 34

4 Answers4

1

I have not used curl or wget but you can use sparse checkout to get the similar thing done.

This should solve your problem. :)

0

You could try and combine:

That is (extracting a tar archive from stdin):

git archive --remote git@gitlab.com:<user>/<repo> main | tar -xvf - specificDir
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

As @VonC edit queue is full, here is the correct command line for git archive:

git archive --remote git@gitlab.com:<user>/<repo> main | tar -xvf - specificDir
  • main: is branch name
  • specificDir: specific dir to untar, it's optional
Limmy
  • 53
  • 12
-1

I didn't find any solution to download a specific folder, to download the complete repository I used following approach:

curl --request GET --header PRIVATE-TOKEN:${GITLAB_TOKEN} https://gitlab.com/api/v4/projects/project_id/repository/archive/ | tar -xz -C /tmp/project-name/

Ashwani
  • 1,340
  • 1
  • 16
  • 34