Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete a repo using gh cli #2461

amitkrout opened this issue Nov 23, 2020 · 4 comments

How to delete a repo using gh cli #2461

amitkrout opened this issue Nov 23, 2020 · 4 comments
enhancement a request to improve CLI


Copy link

Describe the feature or problem you’d like to solve

A clear and concise description of what the feature or problem is.

Proposed solution

How will it benefit CLI and its users?

I created a repo successfully using gh cli

$ gh repo create --public --confirm
✓ Created repository amitkrout/taxi12345 on GitHub
Initialized empty Git repository in /Users/amit/go/src/
✓ Initialized repository in './taxi12345/

$ git remote -v
origin (fetch)
origin (push)

I am looking for a command like ```gh repo delete <repo_url> [flags]

I could not see any command in the cli doc - for the requirement i am looking.

Additional context

Add any other context like screenshots or mockups are helpful, if applicable.

@amitkrout amitkrout added the enhancement a request to improve CLI label Nov 23, 2020
Copy link

See also : #2010 #1084

Copy link

vilmibm commented Nov 23, 2020

As we said in the linked issue:

We've stayed away from this because it's such a dangerous action and I think we will continue to do that.

It's possible, however, to generate a PAT with the delete_repo scope and then do:

gh alias set repo-delete 'api -X DELETE "repos/$1"'
gh repo-delete vilmibm/deleteme

Copy link

Apart from that, your OAuth token must have admin rights otherwise the following error will occur:

  "message": "Must have admin rights to Repository.",
  "documentation_url": ""
gh: Must have admin rights to Repository. (HTTP 403)

You can update your token at /home/<username>/.config/gh/hosts.yml which should have similar configurations as shown below:
    user: chankruze
    oauth_token: gho_*******************
    git_protocol: ssh

Copy link

You can update your token with the right scopes with gh, there's no need to manually modify the config file.

See #3625 (comment)

In the meantime, for anyone who needs this feature: you can add an alias:

# one time:
$ gh alias set delete 'api -X DELETE repos/$1'
$ gh auth refresh -h -s delete_repo

# usage (WARNING: no confirmation!)
gh delete user/myrepo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
enhancement a request to improve CLI
None yet

No branches or pull requests

5 participants