将目录拆分成子模块 [英] Splitting directory into a submodule

查看:113
本文介绍了将目录拆分成子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这里搜寻了一条消息,但似乎没有回答我的问题。
我拥有一个包含当前文件夹结构的git仓库

$ $ $ $ $ $ c $ / app / folder /
/ app / folder2 / ..
/ app / bundles / bundle1
/ app / bundles / bundle2

我希望将bundle中的每个bundle都转换为它自己的子模块,并将该代码的所有版本控制历史记录保留在该bundle中,同时保持目录布局完全相同。原因是我有另一个应用程序,我想要使用一些捆绑包。



我使用了

  git filter-branch --subdirectory-filter bundles / client  -  --all 

但这不是正确的做法....



任何帮助都将不胜感激。

$实际上,使用--subdirectory-filter正是要做的事情,甚至在filter-branch manpage的例子中给出了它。当然,它会用当前活动的分支替换一个新分支,包含操作的结果。原始分支(指向它的指针)通常保存在refs / original /中(请参阅联机帮助页中的--original选项)。
您可以将活动分支复制到别处:

  git branch bundles / client 


并恢复当前分支

  git reset --hard original / refs / heads / oldbranchname 

您可以将活动分支导出为捆绑或直接在子模块中获取,并从父库中删除引用。



如果使用了filter-branch选项,所有分支都会遭受所以你必须重复每一个操作。



不幸的是,你不能把输出分支名称给filter-branch命令。可能值得在Git邮件列表上提出建议。


I've had a goodle and a search on here but nothing seems to answer my question so here goes. I have a git repository with the current folder structure

   /app/folder/
   /app/folder2/..
   /app/bundles/bundle1
   /app/bundles/bundle2

I'd like to turn every bundle in bundles into its own submodule, keeping all the version control history for the code in that bundle, keeping the directory layout exactly the same. The reason for this is I have another app where I want to use some of the bundles.

I had a go at using

git filter-branch --subdirectory-filter bundles/client -- --all

But this was not the right thing to do....

Any help would be greatly appreciated.

解决方案

Actually, the use of --subdirectory-filter was exactly the thing to do, it is even given in the examples of filter-branch manpage. Of course, it will replace the currently active branch with a new one, containing the result of the operation. The original branch (the pointer to it) is usually saved in "refs/original/" (see --original option in the manpage). You can copy the active branch somewhere else:

git branch bundles/client

and restore the current branch

git reset --hard original/refs/heads/oldbranchname

You can than export the active branch as a bundle, or fetch it directly in a submodule and remove the reference from the parent repository.

If the --all option to filter-branch was used, all branches suffer the fate of the active branch, so you have to repeat the copy operation for each.

Sadly, you cannot give the output branch name to filter-branch command. Might be worth a suggestion on Git mailing list.

这篇关于将目录拆分成子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆