比如你有一个repertory的仓库,目录如下:
repertory
├── repertory1
├── repertory2
└── other
打算把other拆分出来
克隆repertory 并到库目录
repertory
├── repertory1
├── repertory2
└── other
打算把other拆分出来
克隆repertory 并到库目录
git clone git@github.com:tom/repertory.git cd big-project把所有other目录下的相关提交整理为一个新的分支new
git subtree split -P other -b new另建一个新目录new并初始化为 git 仓库
git init拉取旧仓库的new分支到当前的 master 分支
git pull new目录 new清除一个other目录下所有内容和记录
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch other" --prune-empty master提交修改后的repertory库
git remote add origin git://github.com:tom/repertory.git git push origin -u master
Git
最后修改于 2017-08-10 09:48:32