由于gerrit仓库可以配置权限,所以会比gitlab仓库多一些分支。
#1. git clone Gerrit空仓库 git clone "http://xxx@gerrit.xxxx.com:80/a/reponame" #2. git remote set-url gitlab_url (旧仓库) git remote set-url origin "https://xxx@git-server.xxx.ai/reponame.git" #3. 拉取所有分支到本地 git fetch git checkout master git pull --allow-unrelated-histories setopt interactivecomments git branch -r > ../branch.txt let count=0 while read br; do let count=$count+1 # echo "$count--$br" if [ $count -eq 1 ];then continue; fi br=`echo $br|sed -r "s/.*origin\/(.*)$/\1/g"` echo "==current branch : $br" git checkout "$br" done < ../branch.txt #4. git pull –all –allow-unrelated-histories#指定允许拉取不相关的代码过来Merge, 有多个分支时,要把多个分支都拉下来,注意用户名: git config username#注释: git pull = git fetch + git merge git pull --all --allow-unrelated-historie #5. git remote set-url Gerrit_url#(指定新 Gerrit 代码库的地址) git remote set-url origin "http://xxx@gerrit.xxxx.com:80/a/reponame" #6. git push -u origin –all#git push -u origin –tags#把代码推送给 Gerrit 仓库 git push --all ; git push --tags