我们要把每个项目变成独立的git仓库,并且保留commit记录。
根据1
项目原始文件:
MyHugeRepo/
.git/
DIR_A/
DIR_B/
DIR_C/
DIR_D/
首先在MyHugeRepo的父目录中执行:
git clone MyHugeRepo MyHugeRepo.tmp
cd MyHugeRepo.tmp
得到DIR_D的git仓库:
git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_A/* DIR_B/* DIR_C/*' HEAD
cd .. 返回 MyHugeRepo.tmp的父目录
git clone MyHugeRepo.tmp DIR_D 重置refs

重复执行上述git clone等,将git filter-branch替换成下面的命令,得到DIR_C的git仓库:
git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_A/* DIR_B/* DIR_D/*' HEAD
依次类推

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐