svntogit git rebase git cherrypick

第一步:
安装 svn2git  : sudo apt-get install svn2git

git svn fetch –authors-file=userinfo.txt

git svn init svn+ssh://svn@10.20.30.18/svn-repos/mtk6735m-aly/ –no-metadata –trunk=trunk-android/pb3.2.0/ –branches=branches/ –branches=branches-android/ –branches=trunk/ gitproject

第一步:创建裸库
git init –bare
第二步 : 添加远程git服务器地址(从svn转git的库,指向裸库),即裸库视为原始库的服务器
git remote add origin file:///home/topwise/zyfcode/new-mtk6735m-aly
第三步:创建新分支跟踪远程分支(在svn转git的库上做,即原始库上做)
vim .git/config 查看远程分支信息
git log –graph –decorate 查看log : 当前分支指向
git log –graph remotes/branches-android/pb3.2.0 查看log
git branch trunk-pb3.2.0 remotes/trunk/pb3.2.0 创建新分支跟踪远程分支
第四步:推送全部的分支到git服务器上
git push –all origin

git push origin local_branch:remote_branch

这个操作,local_branch必须为你本地存在的分支,remote_branch为远程分支,如果remote_branch不存在则会自动创建分支。

类似,git push origin :remote_branch,local_branch留空的话则是删除远程remote_branch分支。

脚本:
1、cherry-pick.sh 用于将需要批量处理的commit逐个cherrypick,失败的commit记录下来,跳过。

*************************************

!/bin/bash

用于批量处理cherry-pick

参数说明: 1commit; {2} 为输出信息 ; ${3} temp file

echo 1>> {2}
echo ‘执行开始’ >> ${2}
i=0
for line in tac ${1}
do
cmdstr=cat cmd.txt
if [ -n “${cmdstr}” ]
then
break
fi

不是合法的commit id,跳过

sha1=echo "${line}" | grep -E "^[a-f0-9]+$"
echo —— sha1 {line}
if [ -z “${sha1}” ]
then
continue
fi

((i= i+1))echo.. {i}......................................................... >> 2echo {line} start >> 2gitcherrypick line 2> 3if[ ? -ne 0 ]
then

过滤merge 的 commit

#slog=`git log $line --oneline | grep "^[a-f0-9]* Merge "`
    slog=`git show $line --oneline --summary | grep "^[a-f0-9]* Merge "`
if [ -z "${slog}" ]
then
        info=`cat ${3} | grep "git commit --allow-empty"`
    if [ -z "${info}" ]
    then
        errinfo=`cat ${3} | grep "Aborting commit due to empty commit message"`
        if [ -z "${errinfo}" ]
         then
         #output erroinfo
         allerrorinfo=`cat ${3}`
         echo ${allerrorinfo} >> ${2}
         sed -i "s/^${line}/error_${line}/" "${1}"
         git cherry-pick --abort
         else
         sed -i "s/^${line}/empty_message_${line}/" "${1}"
         git commit --allow-empty-message --no-edit
        fi
    else
         sed -i "s/^${line}/empty_${line}/" "${1}"
         git commit --allow-empty --no-edit
    fi
else
    sed -i "s/^${line}/merge_${line}/" "${1}"   
fi
 else
        sed -i "s/^${line}/ok_${line}/" "${1}"
 fi 
echo ${line} end >> ${2}

done
echo ……………………………………………………………………………….. >> ${2}
echo ‘执行完毕’
read yourcomd
*************************************

2、cherry-pick–edit.sh 这个脚本用于将上面脚本自动处理不了的commit,逐个cherrypick ,有人工介于的机会。

*************************************

!/bin/bash

用于批量处理cherry-pick

参数说明: 1commit; {2} 为输出信息 ; ${3} temp file

echo 1>> {2}
echo ‘执行开始’ >> ${2}
i=0
for line in tac ${1}
do
((i= i+1))echoaaaaaaaaaaaaaaaaaaaaaaaaa {i} aaaaaaaaaaaaaaaaaaaaaaaaaaaa
echo …………… ${line} start ………………

sha1=`echo  "${line}"  | grep -E  "^[a-f0-9]+$"`   
echo ------ ${sha1} ------ ${line} 
  if [ -z "${sha1}" ]
    then
    continue
    fi
git cherry-pick $line 2> ${3}
 #git cherry-pick $line 2>&1 | tee ${3}
 if [ $? -ne 0 ]
then

过滤merge 的 commit

cat ${3}
#slog=`git log ${3} --oneline | grep "^[a-f0-9]* Merge "`
slog=`git show $line --oneline --summary | grep "^[a-f0-9]* Merge "`
if [ -z "${slog}" ]
then
        info=`cat ${3} | grep "git commit --allow-empty"`
    if [ -z "${info}" ]
    then
        errinfo=`cat ${3} | grep "Aborting commit due to empty commit message"`
        if [ -z "${errinfo}" ]
         then
         #output erroinfo
         allerrorinfo=`cat ${3}`
         #echo ${allerrorinfo} 
         sed -i "s/^${line}/proc_${line}/" "${1}"
         break
        #if [ ${yourcmd} = "continue" ]
        #then
        #echo ${line} continue
        #fi
        #if [ ${yourcmd} = "break" ]
        #then
        #break;
        #fi
         else
         sed -i "s/^${line}/empty_message_${line}/" "${1}"
         git commit --allow-empty-message --no-edit
        fi
    else
         sed -i "s/^${line}/empty_${line}/" "${1}"
         git commit --allow-empty --no-edit
    fi
else
    sed -i "s/^${line}/merge_${line}/" "${1}"   
fi
 else
        sed -i "s/^${line}/ok_${line}/" "${1}"
 fi 
echo ............. ${line} end ...............

done

*************************************

3、getsha1.sh 将 git log –oneline提取的commit信息列表中,提取sha1值。
*************************************

!/bin/bash

用于将在log中截取sha1值 ; 参数说明 : ${1} 为需要处理的文件名

sed -i “s/(^[a-f0-9]) ./\1/” ${1}
*************************************

4、del_sha1.sh 将不需要cherry pick的commit列表,从目录列表中清除
*************************************

!/bin/bash

用于处理git cherry-pick的commit列表,将需要删除的commit删除掉

参数说明 : 1commit; {2} 待处理cherry-pick的commit列表的文件(目标处理文件)

echo 1echo {2}
i=0
strfind=””
for line in cat ${1}
do
((i=$i+1))

strfind=” lineecholine( i):" "strfind”  
sed -i “/^
{strfind}/d" "${2}”
done
*************************************

5、del_line_startwith.sh
*************************************

!/bin/bash

用于将以${1} 开始的行删除

参数说明 : 1; {2} 待处理的文件(目标处理文件)

echo 1echo {2}
sed -i “/^ 1/d"" {2}”
*************************************

svn log –xml file:///home/svn-repos/mtk6735m-kk-aly/ | grep /author | sort -u | awk -F ‘[

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值