正常情況下,如果需要刪除GitHub上不需要的repos
,手動刪除的操作有點繁瑣。如果只要刪除一個還能接受,手動刪除多個repos就有點浪費時間了。其實我們可以通過GitHub的API介面來批量刪除不需要的repos
。
- 將要刪除的
repos
按照username\repos-name
的格式以一行一個存放到文字檔案中。

-
在GitHub上申請具有刪除
repos
許可權的token
。
-
在命令列中執行下面的命令:
- 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"} }
複製程式碼