在另一个git仓库中维护Git仓库 [英] Maintaining Git repo inside another git repo

查看:186
本文介绍了在另一个git仓库中维护Git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含在AngularJS web应用程序中的git repo。

它有一个名为build的子文件夹,它由gulp任务创建。我正在部署到Azure,因此它直接连接到我的bitbucket目录。

我想将build文件夹作为一个独立的git仓库,从中部署Azure应用程序。如何在Git中实现这一点?

解决方案

您有以下几个选项:




  • 子模块
  • 子树





  • $ b


    子模块 允许外部存储库嵌入源代码树的专用子目录 中,始终指向特定的提交。






    git子模块



    将您的大项目分解为子项目,至此为止。

    现在使用以下命令将每个子项目添加到您的主项目中:

      git submodule add< url> 

    一旦投影被添加到您的回购库中,您必须初始化并更新它。

      git子模块init 
    git子模块更新

    Git 1.8.2 添加了新选项 - 远程

      git submodule update --remote --merge 



    $ c>将它们合并到 签出 子模块的最新版本。



    正如






    git subtree em>



    非常类似于子模块,但主要区别在于代码的管理位置。在子模块中,内容被放置在一个单独的回购站中,并在那里进行管理,这样您就可以将其克隆到其他许多回购站。

    subtree 是将内容作为根项目的一部分进行管理,而不是在单独的项目中进行管理。

    <而不是写下如何设置和理解如何使用它,你可以简单阅读这个优秀的文章,这将解释这一切。



    https://developer.atlassian.com/blog/2015/05/ the-power-of-git-subtree /


    I have a git repo which contains in AngularJS web app.

    it has a subfolder called build which gets created by gulp task. I am deploying to Azure so it is connected directly to my bitbucket directory.

    I want to make build folder as a separate git repo from which Azure app is being deployed. How do i achieve this in Git ??

    解决方案

    You have several options like:

    • submodule
    • subtree

    Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.


    git submodule

    Break your big project to sub projects as you did so far.
    Now add each sub project to you main project using :

    git submodule add <url>
    

    Once the projected is added tot your repo you have to init and update it.

    git submodule init
    git submodule update
    

    As of Git 1.8.2 new option --remote was added

    git submodule update --remote --merge
    

    will fetch the latest changes from upstream in each submodule, merge them in, and check out the latest revision of the submodule.

    As the docs describe it:

    --remote

    This option is only valid for the update command. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s remote-tracking branch.

    This is equivalent to running git pull in each submodule.


    However, how would I push a commit in the scenario of bug fix in C which affects the code shared with the parent layers?

    Again: using submodule will place your code inside your main project as part of its content. The difference between having it locally inside the folder or having it as part of a submodule is that in submodule the content is managed (commited) to a different standalone repository.


    This is an illustration of submodule - project inside another project in which each project is a standalone project.


    git subtree

    Git subtree allows you to insert any repository as a sub-directory of another one

    Very similar to submodule but the main difference is where your code is managed. In submodules the content is placed inside a separate repo and is managed there which allow you to clone it to many other repos as well.

    subtree is managing the content as part of the root project and not in a separate project.

    Instead of writing down how to set it up and to understand how to use it you can simply read this excellent post which will explain it all.

    https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/

    这篇关于在另一个git仓库中维护Git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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