开发者

Mac specific optimizations in ~/.gitconfig [closed]

开发者 https://www.devze.com 2023-01-20 04:47 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I read that discuss开发者_高级运维ion about the content of "~/.gitconfig" on Linux: https://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain

I know some Mac specific optimizations, such as using "mate" as default editor:

[core]
    editor = mate -w

or using opendiff as diff editor:

[diff]
    external = opendiff

Do you know other Mac specific optimizations (and/or tools) that I could install/configure in "~/.gitconfig" file in order to get a very user-friendly git?


I use opendiff and textmate as external tools for git. You can configure them by running the following commands in 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

Alternatively you can configure the gitconfig file by adding the following:

[diff]
    tool = opendiff

[merge]
    tool = opendiff

[core]
    editor = mate -w

The difftool and mergetool is only available after version 1.6.3


Since git reuses the same temporary file for commit messages, I recommend using

[core]
    editor = mate -wl1

so TextMate puts the cursor onto the first line every time instead of remembering the cursor position from last time.

And if you create the following shell script...

#!/bin/sh
#
# ~/bin/git-opendiff.sh
#
/usr/bin/opendiff "$2" "$5" -merge "$1"

...and configure git to use it as external diff tool...

$ git config --global diff.external ~/bin/git-opendiff.sh

...you can use opendiff for diffs and merges.


I prefer to keep the default diff command internal, for quick summaries at the terminal, and access the more advanced diff programs (I use MacVim) using the difftool commmand. I describe the set up procedure here. The Mac-specific part is in my wrapper script, where I facultatively launch MacVim if it is available, then default to regular Vim. You can adapt to use TextMate, of course, if that is your preference.

0

精彩评论

暂无评论...
验证码 换一张
取 消