svn大倉庫拆小倉庫遷移保留commit
阿新 • • 發佈:2018-08-24
roo 好項目 完成 lte du -sh int for gis ash 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 : [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