背景:
仓库A:ssh://xxxx.com:port/A.git
仓库B: ssh://xxxx.com:port/B.git
仓库B引用仓库A,作为一个子文件夹使用
构建:
从远程仓库将B拉到本地文件夹 B
在仓库B根目录下增加.gitmodule文件,内容为
[submodule "A"]
path = A
url = ssh://xxxx.com:port/A.git
然后在B的根目录中执行:
git submodule update --init --recursive --remote --merge --force
会将仓库A从远程仓库中拉下来,并放在文件夹A中
然后正常进行提交即可 git add; git commit; git push
更新:
如果仓库A更新了;仓库B需要将最新的仓库A代码更新下来,执行以下操作
在A文件夹中,执行:
git checkout master
然后回到B文件夹中,执行
git submodule sync
然后正常的提交即可 git add; git commit; git push