Gitリポジトリを移行するには?
はじめに
Gitホスティングサービスを、GitLabからBitBucketへ移行する必要があったのでメモです。
移行対象は、単純にリポジトリのみとします。*1
やりかた
1.移行先の空リポジトリを作成します。*2
2.移行元のリポジトリをベアリポジトリとしてクローンします。
git clone --mirror [移行元リポジトリのURL]
3.移行先のリポジトリをリモート(ここではdestination)に追加します。
cd [リポジトリ名] git remote add destination [移行先リポジトリのURL]
4.移行先リポジトリに反映します。
git push destination master
git push --mirror destination
補足: 移行後に移行元のリポジトリにコミットしてしまったら?
あとから同期をとるには、次の手順を踏めばOK!
cd [リポジトリ名] git fetch --all git push destination --mirror