🦊

GitlabのMRを、Githubに移動させてPRを作る

2023/05/18に公開

会社でGitlabからGithubに移行して、そのときにMRも移し替えたのでメモ

Gitlab側

# 最新にしておく
$ git checkout main
$ git pull

# 現状を確認
$ git remote -v
origin	git@gitlab.com:GITLAB_REPOSITORY_URL (fetch)
origin	git@gitlab.com:GITLAB_REPOSITORY_URL (push)

# GithubのリポジトリからSSH URLをコピーしてきて追加
$ git remote add github git@github.com:REPOSITORY_URL

# 追加されていることを確認
$ git remote -v
github	git@github.com:GITLAB_REPOSITORY_URL (fetch)
github	git@github.com:GITLAB_REPOSITORY_URL (push)
origin	git@gitlab.com:GITHUB_REPOSITORY_URL (fetch)
origin	git@gitlab.com:GITHUB_REPOSITORY_URL (push)

# Gitlabのローカルから、Githubのリモートにpushする
$ git checkout YOUR_BRANCH_NAME
$ git pull
$ git push github YOUR_BRANCH_NAME

Github側

$ git fetch
$ git checkout YOUR_BRANCH_NAME
$ git rebase main
Successfully rebased and updated refs/heads/YOUR_BRANCH_NAME.
$ git push -f

PRが作られているのであとは、MRの概要のMarkdownをPR側にコピペして移行終わり🎉

Discussion