當原本的 remote repository 位於私人網域,GitHub 或 Bitbucket 可能無法透過 http 或 ssh 複製 remote repository,此時可以採用以下做法:先將 repository 拉至本地端,再重新 push 新的 repository 上。
clone remote repository
git clone ssh://git@my_repo_host/my_repo.git
進入資料庫,將所有 remote branch 拉下來
cd my_repo
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `;
do git branch --track ${branch#remotes/origin/} $branch;
done
刪除原本的 origin
git remote rm origin
git remote -v # Check
新增新的 origin
git remote add origin ssh://my_new_repo_host/my_repo.git
git remote -v # Check
將本地 repository 推上新的 repository
git push -u --all origin