GitLab への Git repository の移動方法についての備忘録

Server

前回,GitLab を設置しましたので,既存の簡易的なリポジトリから引っ越しをします.

まず,GitLab に登録したユーザーでログイン.今回は testuser としました.

testuserlogin

testuser でログイン

ログイン後に表示される Project ページから,+NewProject を選択.

testuserpage

testuser プロジェクトページ

で,適当なリポジトリ名を付けます.一般に,サーバー上のリポジトリ名は ****.git のようにするのが普通ですが,GitLab はこれを自動で行うようで,****.git というリポジトリ名は入力できないようになっています.今回は,テストとして

OpenSSH
The OpenSSH Project. OpenSSH has 3 repositories available. Follow their code on GitHub.

で公開されている openssh-portable で試してみます.リポジトリ名は myopenssh として進めます.

testnewproject

myopenssh 空リポジトリの作成

下に Import project from というメニューがありますが,認証が必要のようで,今回のテストでは不可能なので,この方法は使いません(Apache と ssh で運用していたリポジトリで試してみましたが何故か上手くいかなかった).ということで,とりあえず下にある 「Create project」で空のプロジェクトを作成します.これで,myopenssh プロジェクトページが作成されました.

myopensshproject

myopenssh プロジェクトページ(登録前)

このページで既存の openssh-portable を管理したい訳です.その為にまず,openssh-portable をローカルに clone します.

$ git clone https://github.com/openssh/openssh-portable
Cloning into 'openssh-portable'...
remote: Counting objects: 47153, done.
remote: Total 47153 (delta 0), reused 0 (delta 0), pack-reused 47153
Receiving objects: 100% (47153/47153), 12.88 MiB | 2.43 MiB/s, done.
Resolving deltas: 100% (36910/36910), done.
Checking connectivity... done.
Checking out files: 100% (680/680), done.

git fetch, push するリモートリポジトリを書き換えて,push します.

$ git remote -v
origin  https://github.com/openssh/openssh-portable (fetch)
origin  https://github.com/openssh/openssh-portable (push)

$ git remote rm origin
$ git remote -v
$ git remote add origin http://gitlab.****.local/testuser/myopenssh.git
$ git remote -v
origin  https://gitlab.****.local/openssh/openssh-portable (fetch)
origin  https://gitlab.****.local/openssh/openssh-portable (push)

$ git push -u origin master

これで無事新しい GitLab サーバーに myopenssh に openssh-portable が登録されました.

myopensshrepo

myopenssh プロジェクトページ(登録後)

なお,サーバー上で各ユーザーのリポジトリは,

/var/opt/gitlab/git-data/repositories

で管理されているようですね.

 

 

Server
スポンサーリンク
Following hyt!
hyt adversaria
タイトルとURLをコピーしました