LoginSignup
8
8

More than 5 years have passed since last update.

Cygwin上のGitからWindowsのテキストエディタとWinMergeを利用する。

Last updated at Posted at 2015-08-03

Cygwin上のGitからWindowsのテキストエディタとWinMergeを利用したかったので調べてみました。
今回はホームディレクトリ上の.gitconfigを直接設定しています。

テキストエディタの設定

今回はテキストエディタとしてEmEditorを利用していますので、下記のようにしてみました。
coreセクションにeditorの行を追加します。

引数で新規プロセスで起動するオプションと、文字化け対策として、UTF8でオープンするように指定しています。
Gitから渡されるCygwinのPATHではEmEditor側がオープン出来ないため、cygpathで変換しています。

[core]
autoCRLF = false
whitespace = cr-at-eol
editor = 'C:/Program Files/EmEditor/EmEditor.exe' /sp /cp 65001 "$(cygpath -w "$*")"

WinMergeの設定

.gitconfigに下記を追加します。
こちらもcygpathを利用するのがポイントです。

[merge]
    tool = WinMerge

[mergetool "WinMerge"]
    cmd = '/cygdrive/c/Program Files/WinMerge/WinMergeU.exe' -u -wl -wr \"$(cygpath --windows --absolute \"$REMOTE\")\" \"$(cygpath --windows --absolute \"$MERGED\")\" \"$(cygpath --windows --absolute \"$LOCAL\")\"

[mergetool]
    trustExitCode = false

[diff]
    tool = WinMerge

[difftool "WinMerge"]
    cmd = '/cygdrive/c/Program Files/WinMerge/WinMergeU.exe' -u -r \"$(cygpath --windows --absolute \"$LOCAL\")\" \"$(cygpath --windows --absolute \"$REMOTE\")\"

[alias]
    diffdir = difftool -d

謝辞

下記のサイトを参考にさせていただきました。
http://qiita.com/whitebell/items/4d92bf0af9f4ccca7276
http://hiro-syumi.ldblog.jp/archives/36344168.html
https://github.com/agross/dotfiles/blob/master/profiles/cygwin/git/gitconfig

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8