You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ci-cd/md/GitHub利用shell脚本批量删除仓库.md

1.4 KiB

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

作者:行癫(盗版必究)


一:环境准备

1.Github账户有需要批量删除的仓库

2.一台可以访问Github的Linux服务器

二:批量删除

1.获取Github的token

在 GitHub 的个人设置中,找到 Developer settings -> Personal access tokens然后点击 Generate new token确保勾选上 delete_repo 权限,并生成 Token。

image-20231117151847464

image-20231117151933455

image-20231117152151434

image-20231117152253881

image-20231117152309379

image-20231117152345934

2.批量删除脚本

[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