可以在不克隆仓库的情况下读取回购中的特定文件(通过代码)吗?
我有一个回购列表,我想阅读每个存储库中存在的一些特定文件(全部通过代码完成)。有没有我不必单独克隆每个存储库的方法,而只是读取回购文件中的信息?所有这些存储库都是公开的。谢谢您
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我有一个回购列表,我想阅读每个存储库中存在的一些特定文件(全部通过代码完成)。有没有我不必单独克隆每个存储库的方法,而只是读取回购文件中的信息?所有这些存储库都是公开的。谢谢您
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
https://raw.githubusercontent.com/ {org/user}/{repo}/{branch}/{branch}/{file}/{file}
,示例:变为:https://raw.githubusercontent.com/openai/gpt-3/master/master/readme.md.md
curl {url}
。在这种情况下:输出:
https://raw.githubusercontent.com/{org/user}/{repo}/{branch}/{file}
, example: https://github.com/openai/gpt-3/blob/master/README.md becomes:https://raw.githubusercontent.com/openai/gpt-3/master/README.md
curl {url}
. In this case:Outputs:
如果它是公共存储库,则答案是 Victor Maricato 直接。
如果私人存储库:
您可以在此处找到对此的参考: https://docs.github.com/en/rest/repos/contents?apiversion=2022-11-11-28#get-repository-content
但是,对于私人存储库,您将在base64中获得内容格式以获取简单的bash脚本以获取文件的内容,请使用以下方式:
In case it is a public repository, the answer by Victor Maricato is simple and straightforward.
In case of a private repository:
You can find reference to this here: https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
However, for a private repository you will get the content in base64 format so to get a simple bash script to get the contents of the file use this: