【问题标题】:Mac specific optimizations in ~/.gitconfig [closed]〜/ .gitconfig中的Mac特定优化[关闭]
【发布时间】:2010-10-18 09:45:04
【问题描述】:

我阅读了关于 Linux 上“~/.gitconfig”内容的讨论:https://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain

我知道一些特定于 Mac 的优化,例如使用“mate”作为默认编辑器:

[core]
    editor = mate -w

或使用 opendiff 作为差异编辑器:

[diff]
    external = opendiff

您是否知道我可以在“~/.gitconfig”文件中安装/配置的其他 Mac 特定优化(和/或工具)以获得非常用户友好的 git?

【问题讨论】:

    标签: 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。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2010-12-19
          • 1970-01-01
          • 2017-01-20
          • 2014-01-16
          • 1970-01-01
          • 2010-09-11
          • 1970-01-01
          相关资源
          最近更新 更多