如何從git儲存庫中刪除原點 - How to remove origin from git repository

語言: CN / TW / HK

問題:

Basic question: How do I disassociate a git repo from the origin from which it was cloned?基本問題:如何將 git 儲存庫與克隆它的來源解除關聯?

git branch -a shows: git branch -a顯示:

* master
  remotes/origin/HEAD -> origin/master

and I want to remove all knowledge of origin, and the associated revisions.我想刪除所有的起源知識,以及相關的修訂。

Longer question: I want to take an existing subversion repo and make a number of smaller git repos from it.更長的問題:我想使用現有的 subversion 儲存庫並從中製作一些較小的 git 儲存庫。 Each of the new git repos should have the full history of just the relevant branch.每個新的 git 儲存庫都應該具有相關分支的完整歷史記錄。 I can prune the repo to just the wanted subtree using:我可以使用以下方法將 repo 修剪為想要的子樹:

git filter-branch --subdirectory-filter path/to/subtree HEAD

but the resulting repo still contains all the revisions of the now-discarded subtrees under the origin/master branch.但是生成的 repo 仍然包含 origin/master 分支下現在丟棄的子樹的所有修訂。

I realise that I could use the -T flag to git-svn to clone the relevant subtree of the subversion repo in the first place.我意識到我可以首先使用 git-svn 的 -T 標誌來克隆 subversion repo 的相關子樹。 I'm not sure if that would be more efficient than later running multiple instantiations of git filter-branch --subdirectory-filter on copies of the git repo but, in any case, I would still like to break the link with the origin.我不確定這是否比稍後在 git repo 的副本上執行git filter-branch --subdirectory-filter多個例項更有效,但無論如何,我仍然想斷開與原點的連結。


解決方案:

參考一: https://stackoom.com/question/chmM
參考二: How to remove origin from git repository
「其他文章」