繁体   English   中英

获取托管在 GitHub 上的存储库的 Git 分支列表

[英]Get the list of Git branches for a repository hosted on GitHub

是否有命令行方式来获取托管在 GitHub 中的存储库中可用的分支列表(无需从克隆中创建和运行命令)?

我尝试在显示分支列表并获取内容的 URL 上使用cURL

git ls-remote --heads <repo-url>

git ls-remote的手册页

例如,要获取 Git 的 Git 存储库的分支,请使用

git ls-remote --heads git://github.com/git/git.git

输出:

121f71f0da1bc9a4e1e96be2c3e683191a82a354    refs/heads/maint
f623ca1cae600e97cb0b38131fdd33e4fb669cf8    refs/heads/master
8e148144574e6c6511b591286e44a677a260d760    refs/heads/next
fcdb578342aeaf355c296026af08093b20aab9b4    refs/heads/pu
5321cb29c8f709669c5e4a04f502cd984623592c    refs/heads/todo

使用/branches API:向https://api.github.com/repos/ /一个 GET HTTP 请求。

回复应该是一个对象数组,其中name属性是分支名称。

来源: 列出分支

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM