Harshita
Harshita

Reputation: 147

Fetching repository file list using GitLab Api

In GitLab I have a project / Repository structure as below.

enter image description here

How do i fetch file list from the branches. As of now I can able to fetch file list from master with the help of the below api. Please help.

Upvotes: 0

Views: 986

Answers (1)

Adam Marshall
Adam Marshall

Reputation: 7649

The example from the docs for the operation "Get file from repository" supports query parameters to specify the ref (a commit, branch, or tag):

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb?ref=master"

Everything before the ? is the path to the file, and ref=master is specifying the master branch, but this can be a commit sha, another branch name, or a tag.

Upvotes: 1

Related Questions