Using Git subtrees to split a repository
https://lostechies.com/johnteague/2014/04/04/using-git-subtrees-to-split-a-repository/
We are in a position where we needed to create a new back-end后端 server for an application.
The current application is on a MEAN stack (Mongodb, Expressjs, Angularjs, Node.js), but a new client wants the backend to be deployed onto a JBoss server.
This created a situation where we needed a completely different backend, but the front-end was shared between them.
The approach we opted选择 for was using git subtrees to split the ui code into its own repository and shared between the nodejs repo and the Java repo.
We did this by using the subtree features in git.
To be clear, I would only use this for very specific situations like this.
If possible, keeping things simple in a single repository is usually best.
But if you’re in the same situation, hopefully this will be helpful for you.
Splitting the Original Repository
The subtree commands effectively take a folder and split to another repository.
Everything you want in the subtree repo will need to be in the same folder.
For the sake of this example, let’s assume you have a /lib folder that you want to extract to a separate repo.
假设你想把lib文件夹提取成一个独立的版本库
1.Create a new folder and initialize a bare git repo:
首先创建一个新的文件夹,并初始化一个空版本库
mkdir lib-repo
cd lib-repo
git init --bare
2.准备好一个远端版本库,和本地的进行映射
Create a remote repository in github or wherever for lib project and add that as the origin remote.
3.在原项目的文件夹中,执行subtree的命令,将文件夹处理到一个独立的分支split上
From within your parent project folder, use the subtree split command and put the lib folder in a separate branch:
https://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt
prefix:
Specify the path in the repository to the subtree you want to manipulate.
This option is mandatory for all commands.
git subtree split --prefix=lib -b split
4.使用文件路径的方式,将split分支上推送到之第一步创建的版本库上
Push the contents to the of the split branch to your newly created bare repo using the file path to the repository.
git push ~/lib-repo split:master
This will push the split branch to your new repo as the master branch
From lib-repo push to your origin remote
Now that lib folder lives in it’s new repository, you need to remove it from the parent repository and add the subtree back, from it’s new repository:
git remote add lib <url_to_lib_remote>
git rm -r lib
git add -A
git commit -am "removing lib folder"
git subtree add --prefix=lib lib master
还有更多的内容,有兴趣的可以去原文链接看
https://www.cnblogs.com/chucklu/p/4647625.html 用git filter-branch拆分repository
Using Git subtrees to split a repository的更多相关文章
- git subtree 拆分split repository
subtree出现,是为了取代submodule http://wenku.baidu.com/link?url=ola85Z5tIXJpxCjLTk-dcO81ayXLs68_y6dsmXIa0ni ...
- git如何merge github forked repository里的代码更新?(转)
参考内容:git如何merge github forked repository里的代码更新? [refer to ]http://www.haojii.com/2011/08/how-to-git- ...
- git如何merge github forked repository里的代码更新
git如何merge github forked repository里的代码更新? 问题是这样的,github里有个项目ruby-gmail,我需要从fork自同一个项目的另一个repository ...
- Git CMD - clone: Clone a repository into a new directory
命令格式 git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare ...
- [Git] Github上传新repository后自动合并
原因是新repository中有个与老repository一模一样的名字为".git"的隐藏文件夹,删去后即可: 将整个工程直接复制粘贴出此错误...好蠢: Github控制项目的 ...
- git如何更新fork的repository(Fork一个别人的repository,做了一些改动,再合并别人的更新)
Fork一个别人的repository,做了一些改动,想提交pull request的时候,发现原先别人的repository已经又有了一些更新了,这个时候想使得自己fork出的repository也 ...
- spring-cloud-config-server——Environment Repository(Git Backend)
参考资料: https://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.4.0.RELEASE/single/spring-cl ...
- 如何在一台主机上管理自己的多个git repository
在使用git时,通常是直接ssh-keygen生成默认秘钥.然后将共钥添加到远程仓库,就可以访问了. 但是,当我们有多个repository时,这种方式就不适用了,因为一个秘钥只能关联一个远程仓库. ...
- 从 Git Gui 管理的Repository(库) 提交更改到 Bonobo服务器管理的Repository(库)
要提交更改到Bonobo服务器管理的某个Repository(库),必须先得在Bonobo服务器上有此Repository(库)——简直就是废话.那么怎么才能这个Repository(库)变出来呢?其 ...
随机推荐
- 在C#中创建word文档
在下面文档中 首先引用word组件:Microsoft.Office.Interop.Word 在头文件中写上 using Word = Microsoft.Office.Interop.Word; ...
- Matlab梯度下降解决评分矩阵分解
for iter = 1:num_iters %梯度下降 用户向量 for i = 1:m %返回有0有1 是逻辑值 ratedIndex1 = R_training(i,:)~=0 ; %U(i,: ...
- context--command buffer
今天看了下 context ,因为要找怎么设置command buffer context为设备提供一些状态的设置和管理command buffer & const buffer buffe ...
- [ActionScript 3] 本地安全沙箱问题最快解决方法
使用FLex4.0时, Chrome等浏览器会报 安全水箱问题..... 解决方案: 打开flash全局安全配置面板并在页面中的配置面板中添加可信任的swf文件或者文件夹: 若是记不住全局安全配置 ...
- HDU1013Digital Roots
G - Digital Roots Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- FormCreate & FormActivate & FormShow执行顺序演示
procedure TForm1.FormCreate(Sender: TObject);begin form1.Caption:=form1.Caption +'+Create'; end; pr ...
- ios 判断空字符串
- (BOOL) isBlankString:(NSString *)string { if (string == nil || string == NULL) { return YES; } if ...
- BeanUtils No value specified for Date的解决方法
/** * ConversionException: No value specified for Date的解决方法 */ ConvertUtils.register(new DateConvert ...
- 吊炸天的 PHP 7 ,你值得拥有
2015年的夏天,虽然来得不算火热,但是在互联网技术的夏天,比任何一年都更为火热. 刚刚才结束了 月底的网易.支付宝.携程以及多家云存储厂商的接连故障的坏消息,6月上旬则迎来了编程语言界两大好消息,第 ...
- Wamp Mysql错误消息 语言设置
Wamp Mysql错误消息 语言设置 http://my.oschina.net/wandershi/blog/264347 打开my.ini 找到 [wampmysqld] port = 33 ...