get list of all project branches via api/command line #23776
-
I’m trying to figure out how I can get a list of remote branches without creating a local repository. For example. I want to pull a list of all branches at https://github.com/joomla/joomla-cms.git I will be doing this via either CLI or php dependening on which one will work. either way each time the script is call the url could be different. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi @n6rej, Thanks for being here! I’m sharing the solution you’ve received from Support here as it might help others. There are a few ways that you can do this. I’d recommend from the terminal, and using v3 of our API (REST) you can make a GET request to fetch these specifically (as documented here: https://developer.github.com/v3/repos/branches/#list-branches)
Or if this is a private repository that you have access to then you’ll need to make an authenticated request using either an OAuth / Personal Access Token or using basic authentications (username / password) (as documented here:https://developer.github.com/v3/#authentication):
In the above request you’d substitute the placeholder $TOKEN with your access token. If you’d like to achieve this via PHP there are a number of libraries that wrap around this API, for instance: https://github.com/KnpLabs/php-github-api however this is a third party API so we cannot support issues with the libraries implementation directly (you’ll have to raise an issue on the repository itself). |
Beta Was this translation helpful? Give feedback.
-
TY! I did stumble upon a way that hopefully is ok with staff.
I literally searched for days to figure SOMETHING out. I really appreciate your help. |
Beta Was this translation helpful? Give feedback.
-
I have successfully recieved reponse from the github branches api. However, the response did’nt contain all the branches in my repo but 10 of 100. How could I get all my branches info? Looking forward to hearing from you. |
Beta Was this translation helpful? Give feedback.
-
This is super accurate solution to the problem (for CLI). |
Beta Was this translation helpful? Give feedback.
Hi @n6rej,
Thanks for being here! I’m sharing the solution you’ve received from Support here as it might help others.
There are a few ways that you can do this. I’d recommend from the terminal, and using v3 of our API (REST) you can make a GET request to fetch these specifically (as documented here: https://developer.github.com/v3/repos/branches/#list-branches)
Or if this is a private repository that you have access to then you’ll need to make an authenticated request using either an OAuth / Personal Access Token or using basic authentications (username / password) (as documented here:https://developer.github.com/v3/#authentic…