0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gitlabのバージョンアップ時の移行コマンド

Last updated at Posted at 2020-11-30

概要

gitlabを古いバージョンから新しいバージョンに移行する際に一括実行するコマンドをまとめる。

手順

空のリポジトリを作成

後続のコマンドを実行するために移行先のリポジトリを作成する

コマンドを実行

以下の手順で旧リポジトリ内容をコピー、[xxx]はそれぞれの内容に置換してください。

[domain]:ドメイン名
[group]:グループ名
[project]:プロジェクト名
[old_group]:旧グループ名

git clone http://[domain]/[group]/[project].git [group]/[project]
cd [group]/[project]
 
// 旧リポジトリと接続(タグが取り込まれる)
git remote add -f [project]_old http://[old_domain]/[old_group]/[project].git
 
// 旧リポジトリを取り込み
git merge remotes/[project]_old/master
 
// masterのpush
git push origin master
 
// 全タグのpush(旧リポジトリ接続時に取り込まれている)
git tag|xargs -I{} -n1 git push origin {}
 
 
// ブランチの移行
git branch -r|grep [project]_old/|sed "s|  [project]_old/||g"|xargs -I{} -n1 git checkout -b {} remotes/[project]_old/{}
git branch |sed -e 's/*//g' | xargs -I{} sh -c 'git checkout {}; git push origin  {}'
 
// ワンライナーver
git clone http://[domain]/[group]/[project].git [group]/[project] \
&& cd [group]/[project] \
&& git remote add -f [project]_old http://[old_domain]/[old_group]/[project].git \
&& git merge remotes/[project]_old/master \
&& git push origin master \
&& git tag|xargs -I{} -n1 git push origin {} \
&& git branch -r|grep [project]_old/|sed "s|  [project]_old/||g"|xargs -I{} -n1 git checkout -b {} remotes/[project]_old/{} \
&& git branch |sed -e 's/*//g' | xargs -I{} sh -c 'git checkout {}; git push origin  {}'

上記のコマンドで移行できる内容は以下になる。

  • ブランチ
  • コミットログ
  • タグ
  • ファイル

issueやwebhook、マージリクエストに関しては移行することができないので、手動で移行する形になります(方法があれば教えてください)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?