とりあえずリモートのdevelopブランチを反映したい
複数の修正があり、順不同で反映していくとエラーになる。よく分からんが正解は「リモートのdevelopブランチ」ということだけ分かっている
作成日:2025-02-17, 更新日:2025-04-03
環境
環境は「本番サーバ」と確認用の「ステージングサーバ」。そして、作業用のローカルサーバ(windows)の3つ。
- 本番サーバは「git pull」しかしない
- ステージングサーバは、developブランチとフィーチャーブランチを切替えて確認
- ローカルサーバは、フィーチャーブランチを作成して、作業+「git push」
作業手順
- ローカルサーバでフィーチャーブランチ(f_work1~f_work●●●)を作成して修正
- ローカルサーバで確認のフィーチャーブランチ(f_view_1)を作成して「f_work1~f_work●●●」たちをマージしていく
- ステージングサーバで確認のフィーチャーブランチ(f_view_1)をプル・チェックアウトして確認
- フィーチャーブランチ(f_work1~f_work●●●)の中から、一部が本番反映確定
- ローカルサーバで確認のフィーチャーブランチ(f_view_2)を作成し、本番反映確定した「f_work1~f_work●●●」たちをマージしていく
- ステージングサーバで確認のフィーチャーブランチ(f_view_2)をプル・チェックアウトして確認
- developブランチにフィーチャーブランチ(f_view_2)をマージ
- ステージングサーバでdevelopブランチをプル・チェックアウトして確認
- masterブランチにマージして本番サーバに反映
問題
ステージングサーバでdevelopブランチをプル・チェックアウトして確認しようとしたらエラー
$ git pull From http://example.com/xxx/xxx af72957..05bbac4 develop -> origin/develop hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. booth_save
リモート環境のdevelopブランチが正なので、さしかえる
$ git checkout develop $ git fetch --all $ git reset --hard origin/develop