1. 这里提供一种基于同步git代码的迁移方案
- 先clone出老的responsity的代码
- 然后在拉取所有的远程分支到本地
- 添加新的远程url
- 将代码push到新的url
2. 参考脚本
@echo off
:: clone old repo
git clone old_url
:: 如果clone出来的代码根目录是repo_dir
cd repo_dir
:: fetch all remote branches
git branch -r | findstr /v ">" > tmp.log
set targe=''
setlocal enabledelayedexpansion
for /f %%i in (tmp.log) do (
set remote=%%i
set var=!remote:origin/=!
echo "!var!"
git branch --track !var! !remote!
)
git fetch --all
git pull --all
git remote rename origin old-origin
git remote add origin new_url
git push -u origin --all
git push -u origin --tags
:: del tmp data
del ..\\tmp.log
echo "migrate finish!"
pause
#!/bin/bash
# clone old repo
git clone old_url
# 如果clone出来的代码根目录是repo_dir
cd repo_dir
# fetch all remote branches
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
git remote rename origin old-origin
git remote add origin new_url
git push -u origin --all
git push -u origin --tags
echo "migrate finish!"
网友评论