问题描述
我有一个包含在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 $ c Git子树允许你插入任何一个存储库作为另一个子目录
em>
非常类似于
子模块
,但主要区别在于代码的管理位置。在子模块中,内容被放置在一个单独的回购站中,并在那里进行管理,这样您就可以将其克隆到其他许多回购站。
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
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 addedgit submodule update --remote --merge
will
fetch
the latest changes from upstream in each submodule,merge them in
, andcheck out
the latest revision of the submodule.As the docs describe it:
This is equivalent to running git pull in each submodule.
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仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!