有没有办法将子模块添加到共享目录结构的git仓库中 [英] Is there a way to add a submodule to a git repo that share a directory structure

查看:90
本文介绍了有没有办法将子模块添加到共享目录结构的git仓库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于

/ foo
/ foo / bar
/ foo / bar / me $ b $的目录结构的回购b / foo / bar / you
/ foo / one
/ foo / one / two
/ foo / one / three

我想添加一个子模块,它具有这种结构

/foo/bar/file.txt
/ foo / one / otherfile.txt

There is a submodule I want to add that has this structure /foo/bar/file.txt /foo/one/otherfile.txt

有没有办法将子模块添加到我的repo中,其中子模块共享一些子模块相同的目录结构?
我尝试过使用基本的add submodule命令,但是我得到了'foo'已经存在于索引中的错误,我认为这是因为我的回购已经有一个/ foo目录,它不能添加子目录相同的模块。

Is there way to add that submodule to my repo, where the submodule shares some of the same directory structure? I've tried using the basic add submodule commands, but I get the error that 'foo' already exists in the index, which I take to mean that becuase my repo already has a /foo directory, it can't add the submodule with the same directory.

是否有子模块共享目录结构,但仍然有不同的文件?

Is there anyway to have the submodule share the directory structure, but still have different files?

推荐答案

检查子模块到子文件夹中,例如 / foo / submodule ,所以它看起来像这样:

Check out the submodule into a subfolder, for example /foo/submodule, so it looks like this:

/foo/submodule/foo/bar/file.text
/foo/submodule/foo/one/otherfile.txt

然后只需链接文件您的回购:

Then simply link the files in your repo:

/foo/bar/file.txt --> link to ../submodule/foo/bar/file.txt
/foo/one/otherfile.txt --> link to ../submodule/foo/one/otherfile.txt

这甚至可以扩展为自动更新链接,并在必要时通过git钩子更新子模块时删除死链接。

This could even be expanded to automatically update the links and remove dead links when you update the submodule by a git hook if necessary.

这篇关于有没有办法将子模块添加到共享目录结构的git仓库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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