Ghost 混合开发-Git Submodule使用

一、背景:

1.混合开发

使用Android+ReactNative。两种语言Java和TypeScript。简化:ReactNative为RN

2.Android加载RN模块的时候改动项。

1.assets模块下的bundle文件,bundle文件是RN生成的离线包 2.未来使用RN第三方自定义组件的时候,会在Android 中的setting文件中配置路径,如./rn/node_modules/react-native-linear-gradient/android_

3.不倾入

为了不侵入原有工程的git文件,使用了Git Submodel子模块管理,这个功能可以再一个Git项目工作时,使用另外一个Git项目(第三方开发的Git库或者自行开发的和多个父项目中使用)

二、实操

1.添加子模块

将远程项目 https://github.com/GeekGhost/GhostRnAPP.git 克隆到本地rn文件夹

git submodule add https://github.com/GeekGhost/GhostRnAPP.git rn

添加子模块后运行git status, 可以看到目录有增加1个文件.gitmodules, 这个文件用来保存子模块的信息。

$ git st
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   .gitmodules
        new file:   rn

2.查看子模块

 git submodule 
 1230e5ad9e7fa3245cb20e298a250ad878c59a66 rn (heads/master)

3.更新子模块

更新项目内子模块到最新版本

$ git submodule update

更新子模块为远程项目的最新版本

$ git submodule update --remote

4.克隆包含子模块的项目

克隆父项目

cd rn
git submodule update --init --recursive

npm info underscore

npm install --save react-native

adb reverse tcp:8081 tcp:8081
npm start
经验分享 程序员 微信小程序 职场和发展