【Git】git pull 時のwarning の解消 Pulling without specifying how to reconcile divergent

gitのwarningメッセージ
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.
Pulling without specifying how to reconcile divergentの解決方法
以下の3つのpullで解決することができます。
git config pull.rebase falsegit config pull.rebase truegit config pull.ff only
スポンサードサーチ
git config pull.rebase false
マージを使用する
デフォルトの挙動です。git pull に --rebase option を付けずに実行するのと同じです。
git config pull.rebase false
標準動作では rebase せずに fast-forward 可能な場合は fast-forward を行い、そうでない場合は、 merge commit を生成しようとします。
git config pull.rebase true
リベースを使用する
git pull --rebase を行う場合と同じです。
git config pull.rebase true
git fetch を行った上で、ローカルブランチに対して rebase を実施するので、merge commit が作られずに、コミット履歴が一直線になります。
スポンサードサーチ
git config pull.ff only
ファストフォワードのみを許可する場合
--ff-only option を付けた時と同様、 fast-forward 可能な場合のみ、 fast-forward します。
git config pull.ff only
そうでない場合は、 merge/rebase せず、エラー終了します。
まとめ
スポンサードサーチ
git configに設定
| 影響範囲 | ファイルディレクトリ | コマンド |
|---|---|---|
| システム全体 | /etc/gitconfig | git config --system |
| 各ユーザー | ~/.gitconfig または ~/.config/git/config | git config --global |
| リポジトリ | リポジトリの .git/config | git config --local |
上記設定をgit configにあらかじめ設定をしておくことができます。
| コマンドの値 | config設定の詳細 |
|---|---|
| デフォルト | fast-forwardの場合のみmergeを行い、それ以外の場合はmerge commitを作成する。git pull --ffと同じです。 |
| only | fast-forwardの場合のみmergeを行い、それ以外の場合はmergeはされずにエラーになる。git pull --ff-onlyと同じです。 |
| false | fast-forwardに関わらず常にmerge commitを作成する。git pull --no-ffと同じです。 |
設定内容を確認
git config --list
実装やエラーが解決できない場合
プログラミングの実装やエラーでどうしてもわからない場合はメンターに相談するのが一番です。
考えている、見えている範囲が狭くなり、解決から遠くに行って何時間も、何日も経っていることなんてよくある話です。
そういう時は聞ける先輩や、メンターに相談することが大事です。
僕にも相談可能なので気軽に相談してください。

Twitterからの連絡だと確実ですよ。
オンラインスクールやプログラミングスクールといったプログラミングを学べる方法もあるので、そちらもぜひ活用してもいいと思います。
Web開発で分からない時
オンライン完結型スクール DMM WEBCAMP PROアプリ開発で分からない時
プログラミング×稼げる副業スキルはテックキャンププログラミングについて分からない時
【コエテコ様限定】※ご案内を受けた以外のメディアが使用しても成果は承認されません。
僕への個人でもメンターでも、スクールでもお好きな方を活用ください。

https://qiita.com/tearoom6/items/0237080aaf2ad46b1963#git-co...






