git 将本地克隆的存储库与其 GitHub 源断开链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23788436/
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
Unlinking a locally cloned repository from its GitHub origin
提问by Marcus Junius Brutus
I had a GitHub repository which I decided to delete but continue to maintain only as a local repo on my hard drive. I am now left with the locally cloned repo which maintains all the history and that's fine. However, a number of configuration settings remain that point to the (now deleted) GitHub repo. E.g:
我有一个 GitHub 存储库,我决定删除它,但继续仅作为我硬盘上的本地存储库进行维护。我现在剩下的是本地克隆的 repo,它保留了所有的历史记录,这很好。但是,许多配置设置仍然指向(现已删除)GitHub 存储库。例如:
$ grep github .git/*
.git/config: url = https://github.com/foo/bar.git
.git/FETCH_HEAD:07c0bac92a829f3acb4b2f5c112de5f787f046e4 branch 'master' of https://github.com/foo/bar
What should I do to ensure that my local repo contains no dangling references and that I cannot push upstream from it anymore nor fetch into it? (how do we call such a repo that doesn't have a remote origin?) It is not clear to me which settings to delete / update and which values to use.
我应该怎么做才能确保我的本地存储库不包含悬空引用,并且我不能再从它的上游推送或获取它?(我们如何调用这样一个没有远程源的存储库?)我不清楚要删除/更新哪些设置以及要使用哪些值。
回答by hek2mgl
Issuing
发行
git remote rm origin
will delete the config settings from .git/config
.
将从中删除配置设置.git/config
。
Then issue
然后发出
rm .git/FETCH_HEAD
to get rid of the FETCH_HEAD
which still points to github.
摆脱FETCH_HEAD
仍然指向github的那个。
However, as @gturri said even if those settings are present, your local copy is already "uncoupled" from the github repository. This is because you deleted the remote repository and every action like push/pull/fetch
would lead to an error therefore.
但是,正如@gturri 所说,即使存在这些设置,您的本地副本也已经与 github 存储库“分离”。这是因为您删除了远程存储库,因此每个操作push/pull/fetch
都会导致错误。
回答by gturri
If you've deleted Github's repo, you already can't push or fetch from it (it would yield an error)
如果你已经删除了 Github 的 repo,你就已经不能推送或获取它了(它会产生一个错误)
However, you should remove the reference to the Github repo:
但是,您应该删除对 Github 存储库的引用:
git remote remove origin