32

How can I see a list of all the child repos that have been created from my template repo on GitHub?

GitHub displays how many forks were created from a given repo at the top of the WUI, next to the "stars" and "watches." And you can display a list of links to those users' forks under the "analytics" tab.

How can I get a similar list of all the repos that were created from my template repo on GitHub?

2
  • 7
    I wish there was an answer for this one, I Googled this question and found this thread in GitHub Community. Haven't seen any feedback on this thread, maybe you should vote up this thread, so it will get more attention
    – Meir Gabay
    Commented Sep 15, 2020 at 20:41
  • 1
    You can also request this feature through the feedback form support.github.com/contact/feedback
    – Ian
    Commented Dec 30, 2020 at 20:18

2 Answers 2

8

Eureka! After reading this - Search based on the contents of a repository, the answer was clear! Search by README.md file content!

Use GitHub's search engine and provide a unique combination of words that appear in your README.md file. This is how I do it for my template - 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

To get meaningful search results

  • Sorting with sort:updated
  • Filtering out my user name -user:USERNAME with -QUALIFIER.

Instead of hardcoding USERNAME you can use the keyword @me.

2
  • 9
    Of course this generally won't work, as nothing prevents users from nuking the template's README.md and adding their own content; and people usually do. Commented Oct 11, 2020 at 0:56
  • 5
    That's the best alternative I could find. Do you have a better alternative?
    – Meir Gabay
    Commented Oct 11, 2020 at 7:37
4

Shell scripting and 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

Then, run ./find_repo_by_template.sh <template_repo> to get a listing of repositories that use that template, AFTER setting the org_name variable. My use case required searching within an organization. If you have a different use case, you should be able to easily tweak my script to get the desired results.

3
  • 1
    So this doesn't work for searching all of GitHub.com (ie all users, not just a specific org)? I have no idea how to tweak this to search all users and all orgs. Can you please update the question with how to do that? Commented May 31, 2023 at 13:15
  • This worked perfect for my org!
    – Busch
    Commented Jul 7, 2023 at 15:56
  • Worked perfect for me too, thanks! Commented Jul 12 at 21:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.