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

Closed
amitkrout opened this issue Nov 23, 2020 · 4 comments
Closed

How to delete a repo using gh cli #2461

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

Comments

@amitkrout
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 https://github.com/amitkrout/taxi12345 --public --confirm
✓ Created repository amitkrout/taxi12345 on GitHub
Initialized empty Git repository in /Users/amit/go/src/github.com/redhat-developer/taxi12345/.git/
✓ Initialized repository in './taxi12345/

$ git remote -v
origin https://github.com/amitkrout/taxi12345.git (fetch)
origin https://github.com/amitkrout/taxi12345.git (push)

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

I could not see any command in the cli doc - https://cli.github.com/manual/gh_repo 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
@ShubhankarKG
Copy link
Contributor

See also : #2010 #1084

@vilmibm
Copy link
Contributor

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

@chankruze
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": "https://docs.github.com/rest/reference/repos#delete-a-repository"
}
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:

github.com:
    user: chankruze
    oauth_token: gho_*******************
    git_protocol: ssh

@cristiand391
Copy link
Contributor

@chankruze
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 github.com -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
Labels
enhancement a request to improve CLI
Projects
None yet
Development

No branches or pull requests

5 participants