【Git】Pulling without specifying how to reconcile divergent branches is discouraged. というwarningの対応について
最近Mac内のGitのversionをあげたせいか、git pull origin main
などのコマンドを打った際に、下記のような警告が出るようになった。
hint: Pulling without specifying how to reconcile divergent branches is hint: discouraged. You can squelch this message by running one of the following hint: commands sometime before your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) 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.
翻訳すると下記のようになる。
分岐したブランチをどのように調整するか指定をせずにpullすることは推奨されていません。 このメッセージを消すには、次の pull を行う前に以下のコマンドを実行してください。 git config pull.rebase false # merge (the default strategy) git config pull.rebase true # rebase git config pull.ff only # fast-forward only git config" を "git config --global" に置き換えることで、すべてのリポジトリに対してデフォルトの優先順位を設定することができます。 また、コマンドラインで --rebase、--no-rebase、--ff-only を指定すると、起動するたびに設定されたデフォルトを上書きすることができます。
どうやらGitの 2.27.0
で導入されたメッセージらしい。
そして、今までの動作から変更する必要を感じていない人は、下記のコマンドを打てばOKのようだ。
(上の警告文に書いてある the default strategy
という選択肢を選択する)
git config --global pull.rebase false
この挙動について詳しく書かれた日本語の記事
検索したら上の方に出てきた記事。わかりやすく解説されていて、助かった。
今までMac環境で出てこなかったということは、Gitのversionがそれだけ古かったのか?
ちょうど最近 Command Line Tool for Xcode
の入れ直しなどを行っていたので、そのタイミングで新しいgitに変わったのかもしれない。
ちなみに現在のgitのversionを確認してみると、下記のとおりであった。
$ git --version git version 2.30.1 (Apple Git-130)