「外部マージツールの利用」の編集履歴(バックアップ)一覧に戻る
外部マージツールの利用 - (2011/03/04 (金) 21:45:23) のソース
たとえば、空白を無視してマージさせたい場合、 以下のように指定する。 - マージ用プログラムを作成 $ 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