できない.dev

Git pull で「Need to specify how to reconcile divergent branches」が消えない

Need to specify how to reconcile divergent branches は、pull.rebase を設定すれば消える。
Git 2.33.1 以降、分岐したまま pull すると統合方法の指定を求めて止まる。

公開: 更新:

症状できない · exit 128
git pull
…
fatal: Need to specify how to reconcile divergent branches.
解決後できた · exit 0
git pull
Merge made by the 'ort' strategy.
 a.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 a.txt

2026-09-01 に alpine/git(Git 2.54.0) で実際に打って取った出力。検証環境の詳細

要約

fatal: Need to specify how to reconcile divergent branches は、Git 2.33.1 以降で git pull したときに、ローカルとリモートが分岐していて fast-forward できないのに、統合方法(マージかリベースか)が設定されていないと出る。

既定を曖昧にしないための仕様変更で、不具合ではない。
pull.rebase を一度設定すれば以降は出なくなる。

実行例

ローカルとリモートが分岐した状態で git pull を実行すると、hint で 3 つの設定を提示したうえで fatal になり、終了コードは 128 になる。
git config pull.rebase false を入れてから同じ git pull を打つと ort 戦略でマージが作られ、git log --oneline にはマージコミットと双方のコミットが並ぶ。

warning: You appear to have cloned an empty repository.
$ git pull
From /tmp/tmp.IOKHLi/origin
   2adba68..b15ac78  master     -> origin/master
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.
$ echo $?
128
$ git config pull.rebase false
$ git pull
Merge made by the 'ort' strategy.
 a.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 a.txt
$ echo $?
0
$ git log --oneline
ce86b46 Merge branch 'master' of /tmp/tmp.IOKHLi/origin
3b92cb8 b2
b15ac78 a2
2adba68 base

— 2026-09-01 時点の出力

検証環境Git 2.54.0 / 2026-09-01 検証
検証日
実行環境
alpine/git Alpine Linux v3.24
バージョン
  • Git 2.54.0

この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。

解決策

1. マージで進める(既定に近い挙動)

git config pull.rebase false

分岐時はマージコミットを作って統合する。
チーム開発で無難な既定である。

2. リベースで直線化する

git config pull.rebase true

ローカルのコミットをリモートの先頭に載せ直し、履歴を直線に保つ。

3. 早送りだけ許す

git config pull.ff only

fast-forward できるときだけ pull し、分岐していれば失敗させて手動対応にする。

4. その場限りで指定する

git pull --no-rebase   # マージ
git pull --rebase      # リベース
git pull --ff-only     # 早送りのみ

グローバルに固定したくない場合は、コマンドのオプションで都度指定する。
全リポジトリ共通の既定にしたいときは、上の git config に --global を付ける(例: git config --global pull.rebase false)。

よくある原因

  1. Git の挙動が変わった。
    以前は暗黙にマージしていたが、Git 2.27 で明示的な設定を促す警告が出るようになり、2.33.1 からはこの fatal で止まる。
  2. ブランチが分岐している。
    git pull の前に、リモートにもローカルにも別々のコミットがある。
  3. pull.rebase や pull.ff を一度も設定していない。