码迷,mamicode.com
首页 > 其他好文 > 详细

svn大仓库拆小仓库迁移保留commit

时间:2018-08-24 19:28:49      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:file   语句   cto   rip   please   date   clone   lse   code   

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

[root@node64_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

[root@node64_2 scripts]# cat remove_git.sh 
#!/bin/bash
#author: fitme
#date : 2018/7/10
#email : fitme96@gmail.com
#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 git@gitlab.xxxx.com: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

标签:file   语句   cto   rip   please   date   clone   lse   code   

原文地址:http://blog.51cto.com/674564591/2164067

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!