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 +``` +