如何查看从我的存储库模板 (GitHub) 创建了多少个存储库

问题描述 投票:0回答:3
如何查看从 GitHub 上的

模板存储库创建的所有子存储库的列表?

GitHub 在 WUI 顶部的“星星”和“手表”旁边显示了从给定存储库创建的分叉数量。您可以在“分析”选项卡下显示这些用户分叉的链接列表。

如何获得从 GitHub 上的模板存储库创建的所有存储库的类似列表?

git templates github git-fork
3个回答
8
投票
尤里卡!读完这篇文章 -

根据存储库的内容进行搜索,答案就很明确了!通过README.md文件内容搜索!

使用 GitHub 的搜索引擎并提供 README.md 文件中出现的独特单词组合。这就是我为模板所做的事情 -

unfor19/terraform-multienv

in:readme sort:updated -user:unfor19 "tfmultienv"


github.com/search?q=in%3Areadme+sort%3Aupdated+-user%3Aunfor19+%22%60tfmultienv%60%22&type=repositories

获得有意义的搜索结果

    使用
  • sort:updated
     排序
    
  • 使用
  • -QUALIFIER 过滤 out
     我的用户名 
    -user:USERNAME
您可以使用关键字

USERNAME

,而不是硬编码 
@me


4
投票
Shell 脚本和

gh

 FTW:

#!/bin/bash org_name="MYORGNAME" repo_list=`gh repo list $org_name --limit 1000 | awk '{print $1}'` template_repo=$1 if [ -z "$template_repo" ] then echo "Usage: $0 <template_repo>" echo " List repositories generated from a given template repository" echo "ABORTING!" exit 1 fi echo "Searching for repositories generated from template: $template_repo" for repo in $repo_list do repo_info=`gh api repos/$repo` echo "$repo_info" | jq -r ".template_repository.full_name" | grep "$template_repo" 2>&1 > /dev/null if [ "$?" -eq "0" ] then echo "repo_using_template: $repo" fi done
然后,在设置 

./find_repo_by_template.sh <template_repo>

 变量后,运行 
org_name
 获取使用该模板的存储库列表。  我的用例需要在组织内进行搜索。  如果您有不同的用例,您应该能够轻松调整我的脚本以获得所需的结果。


1
投票
这是使用

gh

 表示特定组织的“一行”(全局搜索不起作用):

gh repo list my-org-name \ --limit 1000 \ --json name,templateRepository \ --jq '.[] | select(.templateRepository.name == "my-template-repo-name") | .name'
我猜这与 

https://stackoverflow.com/a/76373786/253468 是相同的解决方案,只是使用内置的 JQ 和少几千个 API 调用,无需 shell 脚本。

© www.soinside.com 2019 - 2024. All rights reserved.