そういうのがいいブログ

SIerで働く30代サラリーマンSEがインフラエンジニアに憧れてLinux・クラウド・AWSの勉強をするブログ

GitLabのURLを変更する手順

※[PR]当ブログの記事の中にはプロモーションが含まれています。

・GitLabのURLを変更したい。
・具体的な手順を教えてほしい。

こういった疑問に答えます。

本記事の内容

  1. GitLabのURLを変更する手順

この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。

こういった私が、解説していきます。

私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。

GitLabのURLを変更する手順

``gitlab.rb``の中に書かれているURLを変更します。

手順①:現在の設定の確認

/etc/gitlab/gitlab.rb
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://gitlab.sv-mars.com'

手順②:URLを変更

vi /etc/gitlab/gitlab.rb
[root@SV-MARS ~]# vi /etc/gitlab/gitlab.rb

external_url の値を変更します。

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://gitlab.sv-mars.planet.space.com'

手順③:設定変更後の反映

gitlab-ctl reconfigure
[root@SV-MARS ~]# gitlab-ctl reconfigure

GitLabが一度再起動して設定が反映されます。

手順④:新しいURLでGitLabにアクセスできることを確認

http://gitlab.sv-mars.planet.space.com/users/sign_in

手順⑤:クローン元リポジトリ名の変更

現在の状態を確認

git remote -v
[jenkins@sv-neptune mymoney]$ git remote -v
origin  git@gitlab.sv-mars.com:neptune-group01/mymoney.git (fetch)
origin  git@gitlab.sv-mars.com:neptune-group01/mymoney.git (push)

リモートリポジトリを変更

git remote set-url origin git@gitlab.sv-mars.planet.space.com:neptune-group01/mymoney.git
[jenkins@sv-neptune mymoney]$ git remote set-url origin git@gitlab.sv-mars.planet.space.com:neptune-group01/mymoney.git

変更後の確認

git remote -v
[jenkins@sv-neptune mymoney]$ git remote -v
origin  git@gitlab.sv-mars.planet.space.com:neptune-group01/mymoney.git (fetch)
origin  git@gitlab.sv-mars.planet.space.com:neptune-group01/mymoney.git (push)

リモートリポジトリからpullできることを確認

git pull origin master
[jenkins@sv-neptune mymoney]$ git pull origin master
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

The authenticity of host 'gitlab.sv-mars.planet.space.com (192.168.1.114)' can't be established.
ECDSA key fingerprint is SHA256:4IkZ7wwyje●●●●●●●●●●●●●●●●●●●●●●●●●●●●.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitlab.sv-mars.planet.space.com' (ECDSA) to the list of known hosts.
From gitlab.sv-mars.planet.space.com:neptune-group01/mymoney
 * branch            master     -> FETCH_HEAD
Already up to date.

参考記事

souiunogaii.hatenablog.com

souiunogaii.hatenablog.com

インフラエンジニアの勉強ができるオンライン学習サイト

Udemy (オンライン動画学習サイト)

Udemy(ユーデミー)は、オンラインで動画で学習できるサービスです。
ITエンジニア系の講座もたくさん公開されています。

≫Udemy 世界最大級のオンライン学習サイト

Udemyの特徴
  • ユーザー登録すれば、第1回の講座は無料で視聴できる
  • 無料のコンテンツもある
  • 過去に受講した人の人数や、受講した人の評価も表示されるので選びやすい

≫Udemy 世界最大級のオンライン学習サイト

開発の人気オンラインコース