如何从 git 存储库中删除 origin
基本问题:如何将 git 存储库与克隆源的关联解除?
git Branch -a
显示:
* master
remotes/origin/HEAD -> origin/master
并且我想删除所有起源知识以及相关修订。
更长的问题:我想采用现有的 subversion 存储库并从中创建一些较小的 git 存储库。每个新的 git 存储库都应该具有相关分支的完整历史记录。我可以使用以下命令将存储库修剪为所需的子树:
git filter-branch --subdirectory-filter path/to/subtree HEAD
但生成的存储库仍然包含 origin/master 分支下现已废弃的子树的所有修订。
我意识到我可以首先使用 git-svn 的 -T 标志来克隆 subversion 存储库的相关子树。我不确定这是否比稍后在 git repo 副本上运行 git filter-branch --subdirectory-filter 的多个实例更有效,但无论如何,我仍然想断开与原点的链接。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
相当简单:
对于
filter-branch
问题 - 只需将--prune-empty
添加到您的过滤器分支命令中,它将删除任何实际上不包含的修订生成的存储库中的任何更改:Fairly straightforward:
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:删除现有源并将新源添加到项目目录
Remove existing origin and add new origin to your project directory
在我的情况下 gitbranch -r 将继续在本地存储库上显示 origin/master (在我在远程和本地上重命名 master 之后)
这修复了它:
命令:(
之前见过但完全忘记了)
结果:
是的,gitbranch - r 现在显示它已经消失了!
In my case git branch -r would keep showing origin/master on the local repository (after I renamed master on remote and local)
This fixed it:
Command:
(Seen it before but completely forgot about it)
Result:
Yup, git branch -r now shows it's gone!
使用这个> git 显示来源 > git 远程 rm 原点
Use this> git show origin > git remote rm origin