【问题标题】:Mac specific optimizations in ~/.gitconfig [closed]〜/ .gitconfig中的Mac特定优化[关闭]
【发布时间】:2010-10-18 09:45:04
【问题描述】:
【问题讨论】:
标签:
git
macos
configuration
dvcs
【解决方案1】:
我使用 opendiff 和 textmate 作为 git 的外部工具。您可以通过在 bash 中运行以下命令来配置它们:
#TextMate as the default editor
git config --global core.editor "mate -w"
#Opendiff (FileMerge) to resolve merge conflicts:
git config --global merge.tool opendiff
#Opendiff (FileMerge) as diff tool
git config --global diff.tool opendiff
或者,您可以通过添加以下内容来配置 gitconfig 文件:
[diff]
tool = opendiff
[merge]
tool = opendiff
[core]
editor = mate -w
difftool 和 mergetool 仅在 1.6.3 版本之后可用
【解决方案2】:
由于 git 为提交消息重复使用相同的临时文件,我建议使用
[core]
editor = mate -wl1
所以TextMate每次都将光标放在第一行,而不是记住上次的光标位置。
如果您创建以下 shell 脚本...
#!/bin/sh
#
# ~/bin/git-opendiff.sh
#
/usr/bin/opendiff "$2" "$5" -merge "$1"
...并配置 git 将其用作外部差异工具...
$ git config --global diff.external ~/bin/git-opendiff.sh
...您可以使用 opendiff 进行差异和合并。
【解决方案3】:
我更喜欢保留默认的 diff 命令内部,以便在终端快速总结,并使用 difftool 命令访问更高级的差异程序(我使用 MacVim)。我描述了设置过程here。特定于 Mac 的部分在我的包装脚本中,如果 MacVim 可用,我会在其中临时启动它,然后默认为常规 Vim。当然,如果您愿意,您可以适应使用 TextMate。