Githubでレポジトリ移動(ブランチとwikiの移動)
概要
githubでいろんな事情でレポジトリを移し変えないと行けないときってあると思いますが、 そんなときにやる作業(ブランチとwikiの移動)についてまとめてみます。
ブランチの移動
- 必要なブランチをひとまずすべてローカルに持ってくる
- remoteのurlを確認する
$ git remote -v origin git@github.com:sample/repository_a.git (fetch) origin git@github.com:sample/repository_a.git (push)
- remoteのurlを削除
$ git remote remove origin # remoteをもう一度確認すると何もない $ git remote -v
$ git remote add origin git@github.com:sample/repository_b.git # remoteをもう一度確認するとremoteのurlが変わっている $ git remote -v origin git@github.com:sample/repository_b.git (fetch) origin git@github.com:sample/repository_b.git (push)
- defaultとするブランチから順番にpushしていく
$ git push origin develop $ git push origin master ・・・
wikiの移動
- そもそもwikiをcloneしてくる
# wikiって下記のような(レポジトリ).wiki.gitにあるって知ってました? $ git clone git@github.com:sample/repository_a.wiki.git $ cd repository_a.wiki
$ git remote remove origin # wikiを指定してやる $ git remote add origin git@github.com:sample/repository_b.wiki.git
- remoteのブランチを上書きする
# 不本意ながらもforce pushを使う $ git push origin master -f
おわりに
bitbucket ↔ github間の移行も同じようにできるの? どなたか教えていただけると。
issueの移行も同じノリで(レポジトリ).issue.gitとかってできたりするの?
今度やってみよう。