LoginSignup
1
3

More than 5 years have passed since last update.

gitlabからgithubへの移行

Last updated at Posted at 2019-03-19

経緯

プライベートで開発するにあたって、プライベートなリポジトリでソース管理をしたかったのでgitlabを選定

開発途中でMSがgithubをお買い上げする。githubのプライベートリポジトリが無料になる。

slack連携とか便利そう、CircleCIとの親和性よさそう。メジャー所を使ってみよう

gitlabからgithubへ移行しよう。

やったこと

gitlabのリポジトリからclone、githubのリモートを追加してpush

git clone --mirror ssh://git@gitlab.xxx.com/hoge/repository.git
cd repository.git
git remote add --mirror=push github ssh://git@github.com/hoge/repository.git
git push github

おまけ

ローカルブランチが特定のリモートブランチを追跡するように設定

# gitlabのリポジトリからクローン
git clone https://gitlab.com/hoge/repository.git repo
cd repo

# githubのリモート追加
git remote add github https://github.com/hoge/repository.git
git fetch github

# リモートの確認
git remote -v

github  https://github.com/hoge/repository.git (fetch)
github  https://github.com/hoge/repository.git (push)
origin  https://gitlab.com/hoge/repository.git (fetch)
origin  https://gitlab.com/hoge/repository.git (push)

# 追跡ブランチの確認
git branch -vv
* develop 2141635 [origin/develop] something comment

# 追跡させたいローカルブランチにcheckoutした状態で
git branch --set-upstream-to=github/develop

git branch -vv
* develop 2141635 [github/develop] something comment

向き先を替えたいだけなら

git remote set-url origin https://github.com/hoge/repository.git

でいいと思います。

1
3
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
1
3