GitHub批量删除仓库

正常情况下,如果需要删除GitHub上不需要的repos,手动删除的操作有点繁琐。如果只要删除一个还能接受,手动删除多个repos就有点浪费时间了。其实我们可以通过GitHub的API接口来批量删除不需要的repos。

  1. 将要删除的repos按照username\repos-name的格式以一行一个存放到文本文件中。
    image.png
  2. 在GitHub上申请具有删除repos权限的token。
    image.png
  3. 在命令行中运行下面的命令:
  • Linux
while read r;do curl -XDELETE -H 'Authorization: token xxx' "https://api.github.com/repos/$r ";done < repos
  • Windows(PowerShell)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
get-content D:\repolist.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method “DELETE” -Headers @{"Authorization"="token xxx"} }
posted @ 2020-04-16 23:26  yifeichong  阅读(2419)  评论(2编辑  收藏  举报