banner



How To Remove Repositories From Github

I have nearly 100 forked GitHub repositories (as shown in the following figure), which make my GitHub account very messy. GitHub only allows a user to delete i repository at a time, and it'southward not a very user-friendly process. Each time, information technology asks for your password and also the repository name for every fork. Hence, deleting hundreds of repositories could take a few hours.

My GitHub profile before cleaning

The capability of deleting a big number of GitHub repositories does non exist in the GitHub UI. However, GitHub has a web service API that can be used to delete a agglomeration of repositories. In this postal service, I try to demonstrate how we can apply the web service API of GitHub and git to delete multiple GitHub repositories.

  1. We assume that yous accept whorl and jq installed. Otherwise, you can use mash install jq on Mac or chocolatey install jq on Windows to install jq.

ii. Apply the following control line to get the names of all your repositories on your Github account.

          curlicue "https://api.github.com/users/your_GitHub_account/repos?per_page=100&page=ane" | jq -r '.[] | .name'        

Getting the list of all repositories

This just returns the repositories on page i and if you accept more than than one page you should change folio number to too get the list of repositories on other pages.

3. Re-create the names of all repositories and paste them in a text editor such as Sublime. Then, merely keep the name of all those repositories that y'all want to delete them . Salvage the file as "repo_list_deleting.txt" on your Domicile directory.

The name of all repositories need to be deleted

4. Now you need to add your business relationship name to the commencement of each line or each repository's name. Doing this line by line could exist very fourth dimension consuming and boring. In Sublime, you can practice it automatically by:

  • Selecting all the lines
  • Going to carte Selection -> Dissever into Lines (Cmd/Ctrl + Shift + L)

This allows you to edit multiple lines at once. Now you can add "your_account_name/" to the kickoff of each line.

Adding account name to all repositories name

v. Annals a new personal access token with a delete_repo permission at https://github.com/settings/tokens/new

Fill out the Note Department

Check delete_repo and then click on Generate token

Copy your personal access token

6. Finally, use the following control line on Mac:

          while read repo; do gyre -X DELETE -H "Authorization: token Your_TOKEN" "https://api.github.com/repos/$repo"; done < repo_list_deleting.txt        

If the in a higher place code does non piece of work endeavor to retype the quotations marks in your terminal.

On Windows:

          become-content C:\repo_list_deleting.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method "DELETE" -Headers @{"Say-so"="token Your_TOKEN"} }        

Note that y'all need to exist on your Home directory for running the in a higher place command.

How To Remove Repositories From Github,

Source: https://medium.com/analytics-vidhya/delete-all-unused-github-repositories-using-github-api-18ea4d17b8e9

Posted by: shumakeroppre2002.blogspot.com

0 Response to "How To Remove Repositories From Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel