9

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

我尝试在显示分支列表并获取内容的 url 上使用 curl。

4

2 回答 2

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

的手册页git ls-remote

例如,要 git 的分支 git repo 使用

$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
于 2012-06-06T09:56:44.517 回答
11

使用 GitHub API:向用户名reponame
发送一个 GET HTTP 请求 回复应该是一个对象数组,其属性是分支名称。
https://api.github.com/repos///branches
name

来源:
https ://developer.github.com/v3/repos/#list-branches

于 2015-09-24T19:46:46.900 回答