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(库)变出来呢?其 ...
随机推荐
- BZOJ 1029: [JSOI2007]建筑抢修 贪心
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1029 小刚在玩JSOI提供的一个称之为“建筑抢修”的电脑游戏:经过了一场激烈的战斗,T部落 ...
- java 的 (PO,VO,TO,BO,DAO,POJO) 解释
最近在给Android写接口,其中服务器数据需要定义VO(Value Object)对象进行封装传输 对于VO ,PO , BO , QO,DAO,POJO概念还是比较模糊,所以在这里记录一下: O/ ...
- Task相关
1.Task的优势: 1)把任务当成变量来用,可以作为参数而传递: 2)可以捕获到异步操作中发生的异常. 2.开始异步 Task.Factory.StartNew(() => Thread.Sl ...
- Binary Indexed Tree 分类: ACM TYPE 2014-08-29 13:08 99人阅读 评论(0) 收藏
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int n, ...
- ios containerViewController
- (void)replaceViewController:(UIViewController *)existingViewController withViewController:(UIViewC ...
- 常用的CSSreset整理
说道CSSreset,大家又爱又恨,cssreset好处是,覆盖了浏览器的默认样式,使前端攻城狮能更加精确的添加样式,各个浏览器中的界面效果都相同.可是大量的.固定的CSSreset也给网页加载带来一 ...
- Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest
题目范围给的很小,所以有状压的方向. 我们是构造出一个数列,且数列中每两个数的最大公约数为1; 给的A[I]<=30,这是一个突破点. 可以发现B[I]中的数不会很大,要不然就不满足,所以B[I ...
- js生成唯一值的函数
利用了js的闭包性质 var uniqueNumber = (( function(){ var value = 0; return function(){ return ++value; }; }) ...
- Grid行编辑插件
//操作列不显示应该就是autoLoad的问题. Ext.onReady(function () { Ext.BLANK_IMAGE_URL = "E ...
- vi/vim使用指北 ---- Moving Around in a Hurry
上一篇文章中,简单列出了一些基本的Vim操作,也列出了很多的光标移动命令,本章主要是有哪些命令可以更快的移动光标. vim的编辑操作,用得最多就是移动光标,对于很少行的文件来说,基本的命令就够用了,但 ...