マージ コミットが作成されると、マージがどのように実行されたかという情報は、残念ながら失われます。git merge
これは、戦略や戦略ごとのオプションなど、競合の外観に影響を与える多くのオプションを受け入れるため、重要です。ただし、デフォルトのマージ オプションとの競合を引き起こす可能性のあるマージを見つけるという合理的なケースをカバーすることが目標である場合は、力ずくで実行することができます。マージ コミットを調べて、それらのマージを再作成し、git が報告するものにフラグを立てます。 .
注: このスクリプトは、多くの異なるコミットをチェックアウトし、すべての反復で実行されますgit reset --hard
。git clean -fdx
git に認識されていない重要なファイルを含まないチェックアウトでのみ実行してください。
#!/bin/bash
old_branch=$(git symbolic-ref --short HEAD)
for commit in `git rev-list --merges HEAD`
do
# find the parents of the merge commit
parents=$(git log -1 --format=%P $commit)
fst=${parents%% *}
rest=${parents#* }
# check out the first parent
git checkout -q $fst
# merge with the rest of them
git merge --no-commit $rest >/dev/null 2>&1
# if there are any conflicts, print the commit and abort the merge
if git ls-files --unmerged | grep -q '^'; then
echo $commit
git merge --abort
fi
# get rid of changes so the next checkout doesnt complain
git reset -q --hard
git clean -fdxq
done
git checkout -q $old_branch