![无需克隆即可获取 git 存储库中的所有文件](https://linux22.com/image/182722/%E6%97%A0%E9%9C%80%E5%85%8B%E9%9A%86%E5%8D%B3%E5%8F%AF%E8%8E%B7%E5%8F%96%20git%20%E5%AD%98%E5%82%A8%E5%BA%93%E4%B8%AD%E7%9A%84%E6%89%80%E6%9C%89%E6%96%87%E4%BB%B6.png)
是否有现有的工具可以执行以下操作:
git-cat https://github.com/AbhishekSinhaCoder/Collection-of-Useful-Scripts
then it will run cat on each file in the repo?
像这样的东西可以工作,但它不会分离文件:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/AbhishekSinhaCoder/Collection-of-Useful-Scripts/contents/ |
jq .[].download_url -r |
xargs curl 2>/dev/null |
bat
答案1
只需对命令行进行少量修改即可实现此目的:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/AbhishekSinhaCoder/Collection-of-Useful-Scripts/contents/ |
jq .[].download_url -r |
xargs -L1 sh -c 'curl "$0" 2>/dev/null | bat'
话虽如此,如果有大量文件,您最终可能会因发出太多请求而受到速率限制,或者您的结果可能会因为分页而导致不完整。如果您不想承担完整克隆的费用,您可能希望进行浅克隆 ( git clone --depth=1
) 或部分克隆 ( )。git clone --filter=blob:none