LoginSignup
1
1

More than 5 years have passed since last update.

Rails プロジェクトのリポジトリ名を変更した際に必要だったこと

Last updated at Posted at 2015-12-08

やりたいこと

Rails プロジェクトのリポジトリ名を変更したい。
また Capistrano でリモート環境にデプロイしているので、変更後もデプロイが成功するようにしたい。

バージョン情報

  • Rails : 4.2.5
  • Git : 2.6.3
  • Capistrano : 3.4.0

手順

以下の手順は Bitbucket で管理している yuno という名前のリポジトリを miyako に変更するという想定です。

01. リポジトリ名を変更する

Bitbucket のリポジトリ設定画面でリポジトリ名を miyako 変更します。
テキストボックスの値を書き換えて保存するだけなので、具体的な方法は割愛します。

02. ローカル環境のディレクトリ名とリポジトリ URL を更新する

$ mv ~/workspace/yuno ~/workspace/miyako
$ cd ~/workspace/miyako
$ git remote set-url origin git@bitbucket.org:quanon/miyako.git

03. Capistrano の設定ファイルを更新する

:application:repo_url の行を更新します。

config/deploy.rb
set :application, 'miyako' # 更新
set :repo_url, 'git@bitbucket.org:quanon/miyako.git' # 更新
set :deploy_to, "/var/www/#{fetch(:application)}"
set :scm, :git

04. デプロイ先のディレクトリ名とリポジトリ URL を更新する

:deploy_to 配下にある repo ディレクトリで git remote set-url を行います。

$ ssh deploy-target-server
$ mv /var/www/yuno /var/www/miyako
$ cd /var/www/miyako/repo
$ git remote set-url origin git@bitbucket.org:quanon/miyako.git

05. Webサーバーの設定を更新する

必要に応じて Apache や Nginx の設定ファイルを更新します。具体的な方法は割愛します。

終わり

以上で、リポジトリ名変更後も Capistrano によるデプロイが成功するようになりました。

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