2010/12/30

git and Beyond Compare 3 on Windows XP + Cygwin

這篇記錄一下我git的設定,使用Beyond Compare 3來做為git的diff與merge時的工具。我的電腦是Windows XP,我用的是Cygwin裡的git,不是msysgit。

修改每個repository裡的.git/config或是家目錄裡面的~/.gitconfig

[diff]
    tool = bc3
[difftool]
    prompt = false
[difftool "bc3"]
    cmd = \"c:/program files/beyond compare 3/bcomp.exe\" "$(cygpath -w $LOCAL)" "$REMOTE"
[merge]
    tool = bc3
[mergetool]
    prompt = false
[mergetool "bc3"]
    #trustExitCode = true
    cmd = \"c:/program files/beyond compare 3/bcomp.exe\" "$LOCAL" "$REMOTE" "$BASE" "$MERGED"

裡面用了cygpath把cygwin下的路徑$LOCAL(類似/tmp/U5VvP1_abc這種東西)轉成windows的路徑,因為bc3是個windows下的軟體。

然後,可以用git difftool來比較檔案,git mergetool來做整合。

關於truExitCode的意思是,若外部工具的exit code可以代表檔案整合的成功與否,那麼就可以設為true,要不然,git mergetool會向使用者詢問整合是否成功。詳情請見說明文件

No comments:

Post a Comment