gitlab get tar of a specific branch via command line

try this

curl http://$yourhost:$port/$yourgroup/$yourrepo/repository/archive.zip\?ref\=$yourbranch\&\private_token\=$yourtoken -o newpackage.zip

Since GitLab 6.2 and issue 5253, it should be:

GET /projects/:id/repository/archive

But that seems for internal use only, since you cannot know the id of a project as a user (only its name).

Don't forget, as shown in ability.rb, that downloading an archive is linked to a permission. Make sure you have that "download_code" permission set for your project.

Here, it must be a permission issue, because, for instance:

wget http://demo.gitlab.com/gitlab/gitlab-recipes/repository/archive.zip

That works just fine, and get the content of that project without any issue.


However, as the OP Chris Maes comments and mentions in issue 6645, as as illustrated by app/models/ability.rb:

 if project && project.public?

... that "dowload_code" feature is only for public projects.


For me the private_token and the sha or ref parameters does not worked together. So, I changed the way, and I tell my private token via a header parameter to the Gitlab API, like this:

wget http://{{your_host}}/api/v3/projects/{{project_id}}/repository/archive?sha={{commit_sha}} --header='PRIVATE-TOKEN: {{private_token}}'