git子项目拆分方法

这种一种比 git filter-repo 使用更顺畅的方式。 git filter-repo 要求单独再clone下项目才能做各种覆盖操作,比较麻烦与危险。

#拆分子目录到分支
git subtree split --prefix=hogwarts-ppt-framework -b ppt
#切换到分支检查文件列表
git checkout ppt
#此时其他目录下的文件也在,不是不在当前的分支里,不影响,只需要检查自己分支下的文件列表即可。
git ls-files
#添加子项目仓库
git remote add ppt git@gitlab.ceshiren.com:ceba/tech/hogwarts-ppt-service.git
#推送
git push ppt ppt:main