Web-dive.log

うみざるさんのプログラミング学習

リモートの最新のmainブランチをローカルブランチに反映させる

チーム開発のプラクティスで以下のエラーに直面。

bootcamp % bin/rails test test/system/reports_test.rb
bin/rails:3: warning: already initialized constant APP_PATH
/Users/yohei/Desktop/bootcamp/bin/rails:3: warning: previous definition of APP_PATH was here
/Users/yohei/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.4.21/lib/bundler/runtime.rb:304:in `check_for_activated_spec!': You have already activated stringio 3.1.0, but your Gemfile requires stringio 3.0.1. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

リモートのmainブランチとローカルブランチに差異があると、 GemfileのGemバージョンに不整合が起きてエラーに繋がるので注意。

これを解消するために、以下を実行してリモートの最新のmainブランチをローカルブランチに反映させる。

- mainブランチに移動する
`git checkout main`
- git pullでmainを最新にする
`git pull origin main`
- 開発用ブランチへ移動
`git checkout be-webtest`
- mergeコマンドでmainの内容を取り込む
`git merge origin/main`

以上の手順でエラー解消を確認した。まだまだGitに関して分かっていないので学習あるのみ。