I'm trying to figure out how I can get a list of remote branches without creating a local repository. For example.
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
Solved! Solved! Go to Solution.
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):
curl -H "Authorization: token $TOKEN" https://api.github.com/repos/joomla/joomla-cms/branches
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).
Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!
I did stumble upon a way that hopefully is ok with staff.
for /f "tokens=3* delims=/" %%f in ('call git ls-remote --heads %repo%') do ( REM check to be sure we got a list of branches back. IF ERRORLEVEL 1 ( ECHO Sorry we couldn't find any branches in the %repo% EXIT /B ) ELSE ( REM yep, we did so lets populate the array of branches. set /a "count=count+=1" REM Populate array set branch[!count!]=%%f ) )
I literally searched for days to figure SOMETHING out. I really appreciate your help.
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.