Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I delete a remote Git repository from the command line (Git Bash)?

I'm trying to remove a remote git repository through Git Bash. I'm aware that I can just delete it through GitHub; however, I want to learn how to do so through the command line. I don't just want to remove the files in it, or replace it, I want to completely delete it. I spent the last two days sifting through forums, articles, blogs and tutorials, and nothing has worked.

Some initial info:

$ git remote -v
thisbranch https://github.com/thisuser/test-repo.git (fetch)
thisbranch https://github.com/thisuser/test-repo.git (push)

$ git status
On branch master
nothing to commit, working directory clean

$ git log
Author: *info*
Date: *info*
   adding a new file
Author: *info*
Date: *info*
   Initial commit

$ git remote -v show thisbranch
* remote thisbranch
  Fetch URL: https://github.com/thisuser/test-repo.git
  Push URL: https://github.com/thisuser/test-repo.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)

Some things I tried:

$ git remote remove https://github.com/thisuser/test-repo.git
error: Could not remove config section 'remote.https://github.com/thisuser/test-repo.git'

$ git remote remove master
error: Could not remove config section 'remote.master'

$ git remote remove thisbranch
*returns nothing*

$ git remote -v
*returns nothing*

I've realized I also never get returned the name 'origin'.

like image 939
dahiana Avatar asked Jan 09 '15 20:01

dahiana


People also ask

How do I remove remote repository?

Removing a remote repositoryUse the git remote rm command to remove a remote URL from your repository.

Which command is used to delete repository in git?

The git rm command can be used to remove individual files or a collection of files. The primary function of git rm is to remove tracked files from the Git index. Additionally, git rm can be used to remove files from both the staging index and the working directory.


2 Answers

As pointed out by BrokenBinary in his comment,

This can't be done.

You cannot delete a remote repo (hosted on GitHub or elsewhere) with Git commands, be it in Git Bash or elsewhere, period. You can delete remote branches (assuming you have write access to them), yes, but not an entire remote repository.

However, the GitHub Developer API allows you to delete, from your shell, a repo hosted on GitHub.

like image 76
jub0bs Avatar answered Oct 13 '22 23:10

jub0bs


As Jubobs mentioned above you can use github dev API, so: curl -u :username -X "DELETE" https://api.github.com/repos/:username/:repo Where :username = your username(github handler) and :repo = a name of a repo you want to get rid of

like image 40
daGo Avatar answered Oct 13 '22 22:10

daGo