没有自己的文件夹的git子模块 [英] git submodule without its own folder

查看:94
本文介绍了没有自己的文件夹的git子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的项目的一些部分,比如我的jQuery插件外部。我正在为此目的寻找子模块。
它们看起来相当完美,因为它们可以在一个集中点进行管理和更新。我唯一的问题是,他们克隆到一个文件夹。
这给了我一个像这样的结构。

  / js 
/ plugin_one
plugin_one .js
/ plugin_two
plugin_two.js

我想要的更像是

  / js 
plugin_one.js
plugin_two.js

这是可以通过子模块实现的,还是我使用了错误的工具?



干杯。

解决方案

子模块非常适合将几个repo连接到一组固定配置中(即一组代表一个固定集每个这些子模块,由他们的父回购记录)



然而,他们总是克隆在他们自己的目录。

他们有一个很多其他gocha也是(请参阅为什么你的公司不应该使用Git子模块)。



一种解决方法是维护两组不同的工作树:一个没有版本的版本,包含所有的文件一起。
一个拥有正常克隆的回购站(即将子模块放在他们自己的目录中)。

您可以在其中完成所有正常操作,但是:对于每个git命令, - git-tree 选项, --git-tree 指向第一个集合(包含所有文件的集合)

  • 完整的 .gitignore 能够忽略任何不属于其特定回购的文件。


    这并不令人满意,并指出子模块(甚至在提供它们的其他VCS中 - 即Hg和subrepos,ClearCase和UCM组件)应该保持独立。



    因此,共享一个JQuery插件可能首先需要重新思考文件组织,以确定这些文件是否确实可以被视为子模块。


    I want to make some parts of my projects, like my jQuery plugins external. I was looking into submodules for this purpose. They seem quite perfect, because they can be managed and updated in one centralized point. My Only problem is, that they clone into a folder. This leaves me with a structure like this.

    /js
       /plugin_one
          plugin_one.js
       /plugin_two
          plugin_two.js
    

    What I want is more like this.

    /js
       plugin_one.js
       plugin_two.js
    

    Is that achievable with submodules or am I using the wrong tool?

    Cheers.

    解决方案

    Submodules are great for linking together several repo into a fixed set of configuration (ie a collection of SHA1 representing a fixed set of each of those submodules, as recorded by their parent repo)

    However, they are always cloned in their own directory.
    And they have a lot of other gocha's too (see "Why your company shouldn’t use Git submodules").

    One way to go around that is to maintain 2 different sets of working tree:

    One not versioned, with all the files together. One with the repos cloned normally (ie with the submodules in their own directory).

    You could do in it all the normal operation but with:

    • --git-tree option for each git commands, --git-tree pointing to the first set (the one with all the file in it)
    • a complete enough .gitignore able to ignore any file which isn't part of their particular repo.

    That is not very satisfactory, and point out that submodules (even in other VCS which offer them -- Hg and subrepos, ClearCase and UCM component, ...) are supposed to be kept separate.

    So sharing a JQuery plugin might first involve a bit of re-thinking the file organization to see if those files can indeed be considered as a "submodule".

    这篇关于没有自己的文件夹的git子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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