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

僤鯓⒐⒋嵵緔 提交于 2021-02-06 16:26:54

问题


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'.


回答1:


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.




回答2:


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




回答3:


To delete a remote repo from cmd line, you can use following command

git push origin --delete remote-reponame



来源:https://stackoverflow.com/questions/27868636/how-can-i-delete-a-remote-git-repository-from-the-command-line-git-bash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!