svn大仓库拆小仓库迁移保留commit
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了svn大仓库拆小仓库迁移保留commit相关的知识,希望对你有一定的参考价值。
svn迁git,及增量更新svn迁git仓库 参考http://blog.51cto.com/674564591/2164060
过程:
1.git svn clone http://10.6.60.40/svn/XXXX/SourceCode --authors-file=/root/author.txt --branches=26prpins backup
2.多少个小仓库cp多少份backup, sh /root/scripts/cp.sh
[[email protected]_2 tmp]# cat /root/scripts/cp.sh
#!/bin/bash
read -p "please enter clone service " clone_service
read -p "please enter service " service_dir
for i in $service_dir
do
cp -a $clone_service $i
done
脚本说明:
1.小仓库cp到root目录下
2.执行脚本前在gitlab创建好项目,获取ssh/http仓库地址
3.在root目录执行此remove_git.sh及cp.sh
[[email protected]_2 scripts]# cat remove_git.sh
#!/bin/bash
#author: fitme
#date : 2018/7/10
#email : [email protected]
#scripts describe: 执行脚本传入二级目录,脚本完成大仓库拆分小仓库,并保留commit记录
if [ $# -eq 1 ];then
up_level_dir=$1
for service_dir in parent registry #for 语句后面parent改为需要拆分的小仓库名
do
exclude_dir=${service_dir}
cd /root/$service_dir
for i in `ls |grep -v "^${up_level_dir}$";ls ${up_level_dir}|grep -v "^${exclude_dir}$"|sed -r s‘#(.*)#‘${up_level_dir}‘/1#‘`
do
git filter-branch --force --index-filter ‘git rm --cached -r --ignore-unmatch ‘$i‘‘ --prune-empty --tag-name-filter cat -- --all > /dev/null 2>&1
done
git checkout -b dev dev
git checkout -b inttest inttest
git checkout -b prod prod
git checkout -b uat uat
git branch -D master
for branch in prod inttest dev uat
do
git checkout ${branch}
ls|grep -v "^${up_level_dir}$"|xargs rm -r
mv ${up_level_dir}/${exclude_dir}/* ./
rm -rf $up_level_dir
git commit -am "remove dir"
git add .
git commit -am "test commit"
done
done
else
echo "example: /bin/bash $0 up_level_dir"
fi
- git remote add origin [email protected]:CoreProjectNew/business/frontend.git
- git push origin --froce --all
清理和回收本地仓库空间
- du -sh .git/ 查看.git目录大小
- rm -rf .git/refs/original/
- git reflog expire --expire=now --all
- git gc --prune=now
- git gc --aggressive --prune=now
- 执行完后确认.git目录文件是否变小
以上是关于svn大仓库拆小仓库迁移保留commit的主要内容,如果未能解决你的问题,请参考以下文章