LoginSignup
0
0

More than 1 year has passed since last update.

【Git】GitHubリポジトリの移行手順

Last updated at Posted at 2021-06-05

GitHubリポジトリの移行手順について、調べた事を纏めます。

作業手順

「--mirrorオプションで実施する方法」「1つずつリポジトリを移行後にpushする方法」
の2つに分別できるかと思います。
※移行前と移行後のgitに関しては、本書では「移行前.git」と「移行後.git」という形で表現します。

--mirrorオプションで実施する方法

以下の--mirrorオプションを付ければ、それで完結する模様。
これがおススメ。

# git clone --mirror 移行前.git
# cd 移行前ディレクトリ
# git push --mirror 移行後.git

1つずつリポジトリを移行後にpushする方法

移行前リポジトリをfetch(ダウンロード)して、1つずつ移行していくといった形です。

① 移行後のgitをcloneしておく。

# git clone 移行後.git
# cd 移行後ディレクトリ

② 移行前リポジトリをremoteとして追加する。

# git remote add ikoumae_origin 移行前.git
# git remote -v
ikoumae_origin 移行前.git (fetch)
ikoumae_origin 移行前.git (push)
origin 移行後.git (fetch)
origin 移行後.git (push)

③ 移行前リポジトリをfetchする。

# git fetch ikoumae_origin

④ 移行前リポジトリから対象ブランチをチェックアウトする。
(※ここでは例として、"feature/test"というブランチ名を取る。

# git checkout ikoumae_origin/feature/test

⑤ ローカルブランチ作成

# git branch feature/test

⑥ 移行後ブランチにpushする

# git push origin feature/test

※※ 後はリポジトリの数分、上記の作業を繰り返して完了。 ※※

終わり

gitの移行手順なんて、ググれば沢山出てくるような情報ですが、
普段作業をしていると、単純なgitのコマンドを忘れたりする事もあるので、
それらも含めて、備忘録として活用してもらえればいいかなと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0