使用Git的项目中的项目 [英] Projects within projects using Git

查看:111
本文介绍了使用Git的项目中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置Git项目来包含其他项目?



例如。我正在开发一个在线地图应用程序。我们与SF一起开发了GPS工具。我们同时开发了一个Python Geomapping脚本和一个不同的问题(只关心geomapping)。我们自己的核心文件将这两者联合起来,并将它们建立在我们需要的应用程序上。

每个项目都必须存在 - 对GPS有兴趣的人只对GPS有兴趣 - 但包含所有其他项目的父项目必须可以作为项目访问。



我花了一些时间试图了解子模块,但它们似乎对所需内容有太多独立性。

另外,如果可能的话,如果每个项目都可以包含一个或两个重叠的脚本。一个Git项目能否包含一个不属于其根的文件,这样当这个文件被任何一个团队更新时,两者都可以受益?



这是可以用Git实现的吗? ?用Mercurial?主机(GitHub,Gitorious)是否重要?



我有将Subversion用于'父'的想法 - 忽略.git文件夹,并使用Gi​​t作为项目(忽略.svn文件夹) - 但这只是最后一招。



编辑:



我不想要子模块:


  1. 当用户下载时,zip不包含子模块( here & here )。
    甚至当合作者尝试设置项目时也是如此。这是一个显示屏。

  2. 子模块被冻结 - 它们不会(轻易地)拿起被指向的项目的最新版本。

  3. 其他原因在下面的奇妙答案中以及在这个 NoPugs的独白

子树合并(下文由Paul介绍给我)不会这样做:很难更新源[一个子树],它被合并到项目中,并且该源必须位于项目的根文件夹之外。作为一个网络应用程序,至关重要的是我所有的页面都在内部链接到一个文件夹中,并且测试和更新直接在该文件夹中完成。 (希望这对其他人是清楚而有用的。)



仍在研究设立'远程分支机构',但其他想法仍然受欢迎。

解决方案

我还没有发现子模块对我所从事的(小型)项目特别有用。一旦你完成了设置,对整个项目的工作就需要为几乎所有的命令添加额外的参数,而且语法并不完全正常。我想如果我从事更大子项目的大型项目,我认为这是一个更有利的折衷方案。

有两种可能性将子项目保持为独立git repos,你从你的主要(整合)回购:


  • 使用子树合并 <一个href =http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html =noreferrer>将你的外部项目引入不同的子目录另一个简单的解释(链接固定)。


  • 在主repo中将每个项目设置为远程分支,并将它们中的每一个合并到您的 master (集成)分支,也包含您的核心文件。这需要遵守一些规定:如果您对主回购库中的外部项目进行了任何更改,则必须在分支中进行更改,然后合并到主回收中;你永远不想融入项目分支。这样可以很容易地将更改发送回外部项目,并且完全可以接受使用Git中的分支。



    您的共享脚本可以作为您的另一个独立分支来处理主要目录,你的外部合作伙伴可以从中取出并推送到远程分支。

  • 如果您尝试运行SVN &安培; Git在同一个目录中,你很难在任何一个系统中使用分支,因为SVN通过复制文件目录进行分支,而Git跟踪指针。这两个系统都不会自动看到你在另一个中创建的分支。我认为'解决方案'比它的价值更麻烦。


    How do I set up a Git project to contains other projects?

    eg. I am working on an online mapping app. We developed a GPS tool together with an outfit in SF. We simultaneously developed a Python Geomapping script together with a different concern (that only cares about geomapping). Our own core files unite the two, and build upon them for the app we need.

    Each of the projects must exist by itself - the folks that have interest in the GPS only have interest in GPS - but the "parent" project which includes all of the others must be accessible as a project.

    I've spent some time trying to understand submodules, but they appear to have too much independence for what is needed.

    Also, if possible, it would be nice if each of those projects could contain one or two overlapping scripts. Could one Git project include a file that is not part of its 'root' so that when this file is updated by either team both can benefit?

    Is this doable with Git? With Mercurial? Does the host (GitHub, Gitorious) matter?

    I have the idea of using Subversion for the 'parent' - ignoring the .git folders, and using Git for the projects (ignoring .svn folders) - but that is only a last resort.

    edit:

    To explain why I don't want Submodules:

    1. When users download, the zip does not include the submodules (here & here). Ditto when even collaborators try to setup the project. This is a show stopper.
    2. Submodules are frozen - they do not (easily) pick up the latest version of the project that is being pointed to.
    3. Other reasons as pointed out in the fantastic answers below and in this monologue at NoPugs.

    Subtree-merging (introduced to me by Paul, below) will not do: It is difficult to update the source [of a subtree] from within the project it is merged into, and that source must reside outside of the 'root' folder of the project. Being a web app, it is vital that all my pages link internally to a folder within them, and that testing and updates be done directly within that folder. (Hope this is clear and useful to others.)

    Still studying setting up 'remote branches' but other ideas are still welcome.

    解决方案

    I haven't found submodules to be particularly useful on the (small) projects I've worked on. Once you've set them up, working on the whole project requires adding additional parameters to almost every command and the syntax isn't completely regular. I imagine if I worked on larger projects with more submodules, I'd see it as a more beneficial tradeoff.

    There are two possibilities that keep the sub-projects as independent git repos that you pull from into your main (integration) repo:

    • Using subtree merge to bring your external projects into separate subdirectories in your main repo that includes your core files. This makes it easy to update the main project from the external projects, but complicated to send changes back to the external projects. I think of this as a good way to include project dependencies, but it wouldn't work so well with shared files. Another simple explanation (link fixed).

    • Set up each project as a remote branch in your main repo and merge from each of them into your master (integration) branch that also contains your core files. This requires some discipline: if you make any changes to the external projects in your main repo, they must be made in the branch and then merged into the master; and you never want to merge into the project branches. This makes it easy to send changes back to the external projects and is a perfectly acceptable use of branches in Git.

      Your shared scripts can be handled as another independent branch in your main directory which your external partners can pull from and push to as a remote branch.

    If you try to run SVN & Git in the same directory, you make it very hard to use branching in either system, because SVN does branching by copying file directories while Git tracks pointers. Neither system would automatically see branches you make in the other. I think that 'solution' is more trouble than it is worth.

    这篇关于使用Git的项目中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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