片方の変更を優先してmerge (ファイル単位)
git merge
でコンフリクトがある場合リザルトでコンフリクトしたファイルの一覧が出力される.
$ git merge develop Auto-merging Setting.py CONFLICT (content): Merge conflict in Setting.py Automatic merge failed; fix conflicts and then commit the result.
masterブランチにdevelopをマージしようとしてコンフリクトがあった場合こんな感じの出力が出る.
このときSetting.pyというファイルにコンフリクトあることがわかる.
ここで,masterを優先させる場合
git checkout --ours Setting.py
developを優先させる場合
git checkout --theirs Setting.py
を実行して
git add Setting.py
git commit
でコンフリクトが解決できる.
片方の変更を優先してmerge (まとめて)
まとめてコンフリクトを解決する場合,
masterを優先させる場合
git merge -Xours Setting.py
developを優先させる場合
git merge -Xtheirs Setting.py
でどちらかのブランチをまとめて優先させてマージできる.