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"} }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM