[英]How to move Git submodule to sub-directory?
guys, I just used submodule to organize some Git repos, here's the address: repos伙计们,我只是用 submodule 组织了一些 Git repos,地址在这里: repos
I want to move all the submodule into a new directory called repos, for examples, jquery -> repos/jquery.我想将所有子模块移动到一个名为 repos 的新目录中,例如 jquery -> repos/jquery。
I change the .gitmodules file, but seems it doesn't work.我更改了.gitmodules文件,但似乎它不起作用。 What should I do?我应该怎么办?
Since git 1.8.5,从 git 1.8.5 开始,
git mv old/submod new/submod
works as expected and does all the plumbing for you.按预期工作并为您完成所有管道工作。 You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving.您可能想要使用 git 1.9.3 或更高版本,因为它包含子模块移动的修复。
Credits: Mike Lowerey from comment below致谢:来自下方评论的 Mike Lowerey
Had the same problem just the moment ago and ended up deleting the submodule reference (as outlined in this article ) and recreating it where i wanted it to go.刚才遇到了同样的问题,最后删除了子模块引用(如本文所述)并在我希望它去的地方重新创建它。
To follow your example of moving submodule jquery
into repos/jquery
按照您将子模块jquery
移动到repos/jquery
的示例
.gitmodules
.从.gitmodules
中删除(通常是三行)子模块引用。.git/config
for references to the submodule and remove them, if existent检查.git/config
以获取对子模块的引用并删除它们(如果存在)git rm --cached jquery
to cut the submodule reference out of the repository执行git rm --cached jquery
将子模块引用从存储库中删除git submodule add git://github.com/jquery/jquery.git repos/jquery
使用git submodule add git://github.com/jquery/jquery.git repos/jquery
重新创建您的子模块引用(就像您以前可能做的那样)In case your submodule was set to specific tag, respectively commit (which you'll surely have in a stable project) you will have set it again.如果您的子模块设置为特定标签,分别提交(您肯定会在一个稳定的项目中拥有),您将再次设置它。
Due to this complex process i am strongly hoping there is (or will be, at least on the git roadmap) a more straightforward way of achieving this.由于这个复杂的过程,我强烈希望有(或将有,至少在 git 路线图上)一种更直接的方法来实现这一目标。 If not, surely some scripts could be fumbled together to do this quicker...如果不是,那么肯定可以将一些脚本组合在一起以更快地完成此操作...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.