From 3a7cc21f1640c189b85653b5888e7744c5356901 Mon Sep 17 00:00:00 2001 From: diandian Date: Fri, 17 Nov 2023 15:26:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md/GitHub利用shell脚本批量删除仓库.md | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 md/GitHub利用shell脚本批量删除仓库.md diff --git a/md/GitHub利用shell脚本批量删除仓库.md b/md/GitHub利用shell脚本批量删除仓库.md new file mode 100644 index 0000000..ff43218 --- /dev/null +++ b/md/GitHub利用shell脚本批量删除仓库.md @@ -0,0 +1,46 @@ +

GitHub利用shell脚本批量删除仓库

+ +作者:行癫(盗版必究) + +------ + +## 一:环境准备 + +1.Github账户(有需要批量删除的仓库) + +2.一台可以访问Github的Linux服务器 + +## 二:批量删除 + +#### 1.获取Github的token + +​ 在 GitHub 的个人设置中,找到 Developer settings -> Personal access tokens,然后点击 Generate new token;确保勾选上 delete_repo 权限,并生成 Token。 + +![image-20231117151847464](https://diandiange.oss-cn-beijing.aliyuncs.com/image-20231117151847464.png) + +![image-20231117151933455](https://diandiange.oss-cn-beijing.aliyuncs.com/image-20231117151933455.png) + +![image-20231117152151434](https://diandiange.oss-cn-beijing.aliyuncs.com/image-20231117152151434.png) + +![image-20231117152253881](https://diandiange.oss-cn-beijing.aliyuncs.com/image-20231117152253881.png) + +![image-20231117152309379](https://diandiange.oss-cn-beijing.aliyuncs.com/image-20231117152309379.png) + +![image-20231117152345934](https://diandiange.oss-cn-beijing.aliyuncs.com/image-20231117152345934.png) + +#### 2.批量删除脚本 + +```shell +[root@xingdiancloud ~]# cat github_delete.sh +#!/bin/bash + +TOKEN="YOUR_PERSONAL_ACCESS_TOKEN" + +repos=("repo1" "repo2" "repo3") # 要删除的仓库列表 + +for repo in "${repos[@]}" +do + curl -X DELETE -H "Authorization: token $TOKEN" "https://api.github.com/repos/YOUR_USERNAME/$repo" +done +``` +