标签:file 语句 cto rip please date clone lse code
svn迁git,及增量更新svn迁git仓库 参考http://blog.51cto.com/674564591/21640601.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
标签:file 语句 cto rip please date clone lse code
原文地址:http://blog.51cto.com/674564591/2164067