问题描述
基本问题:我如何从一个git repo和它被克隆的源头中分离出来?
git branch -a
显示:
* master
遥控器/ origin / HEAD - >原产地/主人
我想删除所有关于原产地和相关修订的知识。
更长的问题:我想采取一个现有的颠覆回购,并从中做出一些较小的git回购。每个新的git回购应该只有相关分支的完整历史。我可以使用以下命令将repo修剪为想要的子树:
git filter-branch --subdirectory-filter path / to / subtree HEAD
,但生成的repo仍然包含原点/主设备下现在丢弃的子树的所有修订分支。
我意识到我可以使用-T标志来git-svn克隆颠覆回购的相关子树。我不确定这会比后来在git repo的副本上运行 git filter-branch --subdirectory-filter
多个实例更高效,但无论如何,我仍然想打破与原产地的联系。
相当简单:
git remote rm origin
至于 filter-branch
问题 - 只需添加 - prune-empty
到您的过滤器分支命令,它会删除任何实际上不包含任何更改的结果repo的修订:
git filter-branch --prune-empty --subdirectory-filter path / to / subtree HEAD
Basic question: How do I disassociate a git repo from the origin from which it was cloned?
git branch -a
shows:
* 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. Each of the new git repos should have the full history of just the relevant branch. I can prune the repo to just the wanted subtree using:
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.
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. 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.
Fairly straightforward:
git remote rm origin
As for the filter-branch
question - just add --prune-empty
to your filter branch command and it'll remove any revision that doesn't actually contain any changes in your resulting repo:
git filter-branch --prune-empty --subdirectory-filter path/to/subtree HEAD
这篇关于如何从git仓库中删除原点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!