たとえば、空白を無視してマージさせたい場合、
以下のように指定する。
以下のように指定する。
- マージ用プログラムを作成
$ cat > extMerge #!/bin/sh ancestor=$1 local=$2 other=$3 diff3 --diff-program=diff-custom -Em \ --label=local $local \ --label=ancestor $ancestor \ --label=other $other \ > $local.$$ res=$? mv $local.$$ $local exit $res
$ cat > diff-custom #!/bin/sh diff -w $*
$ chmod +x extMerge diff-custom $ mv extMerge diff-custom (PATHの通っているディレクトリへ)
- マージドライバの定義を登録
$ cat >> ~/.gitconfig [merge "extMerge"] name = external merge driver driver = extMerge %O %A %B # マージコマンドとコマンドに渡す引数を指定 # %0 共通祖先 # %A カレントブランチのソース状態 # %B マージ対象のブランチのソース状態 recursive = binary # 共通祖先が2つ以上ある場合のマージ方法を指定
- マージ用属性の設定
ファイル名が *.c、*.h の場合にのみ適用する場合
$ cat >> .gitattributes *.c merge=extMerge *.h merge=extMerge
全ファイルで使う場合
$ git config --global merge.tool extMerge
参考: man gitattributes