编辑 ~/.gitconfig

# add
[difftool "sourcetree"]
    cmd = /usr/local/bin/ksdiff -- \"$LOCAL\" \"$REMOTE\"
    path = 
[mergetool "sourcetree"]
    cmd = /usr/local/bin/ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" \"$REMOTE\"
    trustExitCode = true

参考

https://ruby-china.org/topics/14404