如何从命令行 (Git Bash) 删除远程 Git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27868636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:41:00  来源:igfitidea点击:

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

gitgithubrepository

提问by dahiana

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.

我正在尝试通过 Git Bash 删除远程 git 存储库。我知道我可以通过 GitHub 删除它;但是,我想通过命令行学习如何做到这一点。我不只是想删除其中的文件,或者替换它,我想完全删除它。过去两天我一直在浏览论坛、文章、博客和教程,但没有任何效果。

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

我意识到我也从来没有得到过“起源”这个名字。

采纳答案by jub0bs

As pointed out by BrokenBinary in his comment,

正如 BrokenBinary 在他的评论中指出的那样,

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.

您不能使用 Git 命令删除远程存储库(托管在 GitHub 或其他地方),无论是在 Git Bash 还是其他地方,期间。您可以删除远程分支(假设您对它们具有写权限),是的,但不能删除整个远程存储库。

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

但是,GitHub Developer API允许您从 shell 中删除托管在 GitHub 上的存储库。

回答by daGo

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

正如上面提到的 Jubobs 你可以使用 github dev API,所以:curl -u :username -X "DELETE" https://api.github.com/repos/:username/:repoWhere :username= 你的用户名(github 处理程序)和:repo= 你想要摆脱的仓库 的名称

回答by Arunodoy Das Gupta

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

要从 cmd 行删除远程仓库,您可以使用以下命令

git push origin --delete remote-reponame

git push origin --delete remote-reponame