批量删除git仓库

AI摘要
Grace AI
今天想上传内容到GitHub的时候发现以前fork了很多的仓库,大多都已经没有学习的意义了,又或者是和谐了,一个一个删除太过于麻烦,于是在网上搜集了一些方法,在这里记录一下
  1. 申请token
  2. 制作删除仓库的列表文件
  3. 启动powershell

访问 https://github.com/settings/tokens 获取delete_repo的token

33ab4c500520250207180159

cf2cf10a5120250207180222

 

新建一个txt文件,记录你需要删除的仓库

68eeaf1cd020250207180234

 

启动powershell

887e4237a420250207180314

 

输入如下指令

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
get-content E:\github_del.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method “DELETE” -Headers @{"Authorization"="token xxx"} }


# 例如下面,这里需要替换的是repo.txt的地址以及token后面的xxx,双引号要保留
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 
get-content D:\research\delete-repository-in-bulk\repo.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method “DELETE” -Headers @{"Authorization"="token ghp_aoJDtXrLVoKteR3kkBNVyJt4txS"} }

其中需要注意repo的地址以及token,这些都是需要进行替换的

c0c4fcdf2e20250207180529

 

运行成功!

© 版权声明
THE END
喜欢就支持一下吧
分享
评论 抢沙发

请登录后发表评论

    暂无评论内容