LoginSignup
2
1

More than 5 years have passed since last update.

gitlab移行後のremoteの変え方と二段階認証の再設定手順

Last updated at Posted at 2018-08-10

コスト的な都合で環境を移したので。

gitlab移行後に生じること

・ドメインが変わる場合remoteの設定を変える必要がある
・おなじく二段階認証を初期化してあるので再設定が必要となる
・CI連携でWebhookを設定してる場合は関連接続設定とurlの設定を変える必要がある

(SSH鍵認証の再設定は不要)

remoteの変え方

gitコマンドを用いる場合

git remote -v
new_gitlab_url='git://新gitlabサーバのurl/namespace/reponame.git'
git remote set-url origin ${new_gitlab_url}
git remote -v

urlはhttpsではなくgitから始まるものです。

または以下のように直接設定ファイルを編集する

cd ${my_gitrepo_root}
vi .git/config
url = git@${old_gitlab_url}:namespace/reponame.git
↓
url = git@${new_gitlab_url}:namespace/reponame.git

git remote -v

変更後にgit push/pullする

やたらリポジトリが多い人はfind+sedがべんり(変数にみえるURLはリテラルに置換してください)

find /path_to_git_repositorys/*/.git -type f -name "config"|xargs grep ${old_gitlab_url}
find /path_to_git_repositorys/*/.git -type f -name "config"|xargs sed -i 's/${old_gitlab_url}/${new_gitlab_url}/g'

visualstudioは、以下URLにあるように、チームエキスプローラーにて、設定タブを表示、remoteの設定をする
https://opcdiary.net/?p=34613

tortoisegitは以下URLの画像を参考にドメインの部分を変更する
https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-git-remote

2要素認証の再設定

・管理者は移行後に全ユーザの2要素認証の設定を無効化する
http://vamview.hatenablog.com/entry/2016/08/25/232914

・ユーザは初回と同様に右上のアイコン>ProfileSettings>Accontから2要素認証の再設定をおこなう
http://jildin.hatenablog.com/entry/2017/03/20/033736

webUIのログインはスマホアプリのAuthenticatorをつかいますが、
コンテナレジストリにdocker loginする場合はいつもの自分のgitlabのログインパスワードのかわりに生成したトークンをつかいます。

Webhookを設定してある場合、通信先通信元の接続URLとファイアーウォールの設定を更新する

・管理者は移行後に移行前に許可されていた接続元(SSH)を新gitサーバにも許可する

・gitサーバが接続元となるCIサーバなどのファイアウォール設定については個人管理となる

SSHの設定ファイル・hostsなどを更新する

以下はもし必要だった場合に。
hostsの設定は通常は不要(DNSの設定を上書きして検証時など内部DNSが存在しないか優先したい事情がある、グローバルなDNSの設定を制御したい時などに利用)です。
sshはhostの指定だけで鍵オプション書かなくてよくなるので少し便利です。

Unix/Linuxの場合(変数にみえるURLはリテラルに置換してください)

vi ~/.ssh/config
Host ${new_gitlab_url}
    HostName ${new_gitlab_url}
    IdentityFile ~/.ssh/id_rsa
sudo vi /etc/hosts

winのhostsの場所は以下なのでメモ帳やテキストエディタで必要に応じて編集する
C:\Windows\System32\drivers\etc\hosts

Macのhostsの場所は/private/etc/hostsにあるようです。

hostsの編集をするには管理者・root権限が要ります。

以上

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