LoginSignup
0
0

More than 3 years have passed since last update.

warning: Pulling without specifying how to reconcile divergent branches is discouraged.

Last updated at Posted at 2021-01-23

事象 : プルったらなんか警告された

  • 環境
    • macOS Big Sur バージョン11.1
    • git version 2.28.0
$ git pull
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

原因 : リモートに変更があってプルったときにどうするか決めていないから

git pullを実行したとき、Git はまず git fetch を実行し、そのあとに current branch に対して 事前に git fetch で取得したヘッドをマージするように git merge を実行します。

このとき、Git の設定ファイルの中で pull.rebasetrue もしくは false と明示的に設定されているか、 実行時に --rebase などのオプションが指定されていれば、リモートブランチとの差があったときにはそれらに従って差分が解決されます。
Git 2.27.0 から git pull をすると表示されるようになった "Pulling without specifying how to reconcile divergent branches is discouraged." について - esm アジャイル事業部 開発者ブログ

対応 : 提示された選択肢から好きなのを選ぶ

選択肢 意味
git config pull.rebase false fast-forwardする。できなかったらマージしてコミットを作る(プッシュは自分でする)。
git config pull.rebase true rebaseする
git config pull.ff only fast-forwardする。できなかったらエラーにする。

fast-forwardって何?って時はBacklogさるがわかりやすいです。

image.png
このbugfixブランチをmasterブランチにマージする時、masterブランチの状態が以前から変更されていなければ、非常に簡単にマージを行うことができます。 bugfixブランチの履歴はmasterブランチの履歴をすべて含んでいるため、masterブランチは単純に移動するだけでbugfixブランチの内容を取り込むことができます。なお、このようなマージをfast-forward(早送り)マージと呼びます 。
ブランチの統合|サル先生のGit入門【プロジェクト管理ツールBacklog】

# リポジトリごとにやるのは面倒くさいのでGlobalで好みを設定した
$ git config --global pull.rebase false
0
0
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
0
0