备份/镜像 Github 存储库
我想定期创建 github 存储库的备份。有没有一种快速方法可以在不知道整个列表是什么的情况下提取所有这些内容?
沃尔特
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想定期创建 github 存储库的备份。有没有一种快速方法可以在不知道整个列表是什么的情况下提取所有这些内容?
沃尔特
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
现在,接受的答案中使用的 v2 API 不再起作用,是时候使用 Github API v3。
您可以获取 JSON 格式的存储库列表,并
注意分页!默认情况下,结果分页至 30 个项目。如果您的存储库数量超出了单个页面的容纳范围,您将获得一个
Link
HTTP 响应标头,其中包含指向其他页面的链接(rel=next/last/first/prev)。您还可以要求更大的页面大小(最多 100):完整备份脚本(假设您有 100 个或更少的存储库)将如下所示:
Now that the v2 API used in the accepted answer no longer works, it's time for an update that uses Github API v3.
You can get the list of repositories in JSON format with
Watch out for pagination! By default the results are paginated to 30 items. If you have more repositories than fit into a single page, you'll get a
Link
HTTP response header with links to the other pages (with rel=next/last/first/prev). You can also ask for a larger page size (up to 100):A full backup script (assuming you have 100 or fewer repositories) would look something like this:
您可以通过 GitHub 的 API 获取整个列表:
例如,这个简单的 DOS/Unix shell 单行:
打印(假设您安装了 Ruby):
http://github.com/walterjwhite/documentation.server-setup/
You can get the entire list via GitHub's API:
For example, this simple DOS/Unix shell one-liner:
prints (assuming you have Ruby installed):
http://github.com/walterjwhite/documentation.server-setup/
我一直在等待的答案。
我决定尝试一下 Ruby,结果还不错。我喜欢它的紧凑性,但它看起来不太漂亮:(。
这有效:
Walter
The answer I was waiting for.
I decided to give Ruby a try and it is okay. I like how it is compact, but it isn't pretty looking :(.
This works:
Walter