Git添加beyond compare4作为比较工具

栏目: 编程工具 · 发布时间: 6年前

内容简介:使用首先我们找到Git的配置文件“.gitconfig”,在

使用 git diff 或者是 git difftool 命令去比较文件都是在git小黑窗口去打开,比较起来很不友好。所以我们通过配置文件把比较功能强大的“beyond compare4”作为Git的比较工具,这样我们就可以通过命令行调用强大的“beyond compare4”。通过“beyond compare4”工具更加轻松的去比较本地和远程文件的差异性

1.配置“.gitconfig”文件

首先我们找到Git的配置文件“.gitconfig”,在 C:\Users\Administrator\.gitconfig 文件中配置,具体配置如下:

[gui]
    encoding = utf-8
[diff]
    tool = bc4
[difftool]
    prompt = false
[difftool "bc4"]
    cmd = "\"C:/Program Files/Beyond Compare 4/bcomp.exe\" \"$LOCAL\" \"$REMOTE\""
    
[merge]
    tool = bc
[mergetool]
    prompt = false
    keepBackup = false
[mergetool "bc"]
    cmd = "\"C:/Program Files/Beyond Compare 4/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""

mergetool 是merge解决冲突时会弹出对应的运行软件, keepBackup=false 可以防止合并后生产后缀为 .orig 的备份文件

说明: cmd = "\"C:/Program Files/BeyondCompare/bcomp.exe\" \"$LOCAL\" \"$REMOTE\""

表示输入命令 git difftool 后去找对应的运行文件并传(大字符串里面用空格分开)递参数处理。用空格分开(相当于参数), \" 表示单个输入的参数必须为字符串(个人理解)。

  • 第一个表示调用可执行文件的路径
  • 第二个 $LOCAL 表示远程文件临时存储在本地的 C:\Users\Administrator\AppData\Local\Temp\wj9D8b_.eslintrc 中去
  • 第三个 $REMOTE 表示去拿当前需要比较的文件

注意:建议只比较一个文件,否则git会递归对比每一个文件。

配置完成后可以使用 git difftool <文件> ,默认就会打开“Beyond Compare 4”工具

git difftool readme.md

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

An Introduction to the Analysis of Algorithms

An Introduction to the Analysis of Algorithms

Robert Sedgewick、Philippe Flajolet / Addison-Wesley Professional / 1995-12-10 / CAD 67.99

This book is a thorough overview of the primary techniques and models used in the mathematical analysis of algorithms. The first half of the book draws upon classical mathematical material from discre......一起来看看 《An Introduction to the Analysis of Algorithms》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

随机密码生成器
随机密码生成器

多种字符组合密码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具