Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get all the branches of a project using Gitlab API?

Trying to get all the branches under a project using GitLab API, but I can see only 20 branches are returned. How can I get the complete list of all the branches? I am using the following API.

curl --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/1521/repository/branches"
like image 588
Ashish Pratap Avatar asked Oct 17 '25 05:10

Ashish Pratap


1 Answers

Found the solution under pagination in the official Gitlab API documentation, by default we get 20 results, we can increase the number of results by using per_page in our API link as follows.

https://gitlab.com/api/v4/projects/<Project_id>/repository/branches?per_page=50
like image 127
Ashish Pratap Avatar answered Oct 18 '25 23:10

Ashish Pratap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!