GitHub批量删除repository

最近在清理自己的github项目时,发现很多fork的没用的库,想一次性快捷地批量删除,而不是一个一个点进Setting里面手工删除,便找到了这篇文章:

https://juejin.im/post/5c42e2e76fb9a049ba41e06a

总结起来是4步:

  1. 创建一个文件,例如命名为repos.txt,编写需要删除的库:
aaa\repos1
aaa\repos2

aaa 表示自己的用户名,repos1表示repository的名称,需要删除多少,就按照这种格式写多少行,注意用户名与repos之间是反斜杠

  1. 访问https://github.com/settings/tokens ,获取具有删除库权限的token
  2. 终端执行下面命令进行删除:
    • Linux:
      $ while read r;do curl -XDELETE -H 'Authorization: token xxx' "https://api.github.com/repos/$r ";done < repos.txt
      < 是shell中的输入重定向,```xxx就是前面步骤得到的token`,不过该方法我在WSL环境下执行提示SSL错误;
    • Windows Power Shell
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
    get-content repos.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method “DELETE” -Headers @{"Authorization"="token xxx"} } 
    
		执行完后会有类型如下输出:
		![在这里插入图片描述](https://img-blog.csdnimg.cn/20200513232937563.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L291ZW5pbmc=,size_16,color_FFFFFF,t_70)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值