Get all commits from the gitlab api of all branchs, is it possible?

I’m Strugglin with a problem when I need to get all commits of all branchs of my repository, but the API needs a branch specific, Is that possible to get all commits without set a branch

the parameter all → (all boolean no Retrieve every commit from the repository) would be a solution

thanks for your help

The Commits API requires a branch (or ref_name) parameter. If ref_name is not provided, it uses the default branch of the project.

For your use case, I suggest first enumerating all the branches for your repository with the Branches API and then looping through that list using them as ref_name in the Commits API requires a branch (or ref_name) calls.

For example

# get list of branches
GET /projects/:id/repository/branches | jq .[].name
# use list of branches as $branch_name variable and loop commits API endpoint
GET /projects/:id/repository/commits?ref_name=$branch_name
1 Like