Delete Old GitHub Forks

jpoehnelt

Justin Poehnelt

Posted on October 23, 2022

Delete Old GitHub Forks

Was browsing through my GitHub repositories and realized I have an embarrassing number of forks. A lot of these contain code that is either out of date or not even valid anymore. I used the following to quickly cleanup these repositories that I created before 2021-01-01.

gh search repos \
  --owner jpoehnelt \
  --created="<2021-01-01" \
  --include-forks=only \
  --json url \
  --jq ".[] .url" \
| xargs -I {} \
  gh repo delete {} \
    --confirm
Enter fullscreen mode Exit fullscreen mode

You may need to refresh your auth with the delete_repo scope.

gh auth refresh -h "github.com" -s "delete_repo"
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
jpoehnelt
Justin Poehnelt

Posted on October 23, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Delete Old GitHub Forks
github Delete Old GitHub Forks

October 23, 2022