Git使用技巧

Git Windows下配置Merge/Diff工具DiffMerge

参考:Git Windows下配置Merge工具DiffMerge

  1. 下载DiffMerge
    DiffMerge下载地址

    Git使用技巧_第1张图片
    Paste_Image.png

  2. 创建启动DiffMerge脚本

1)在Git的安装路径的\cmd路径下创建以下两个脚本,注意安装路径,见图

git-difftool-diffmerge-wrapper.sh

# place this file in the Windows Git installation directory /cmd folder
# be sure to add the ../cmd folder to the Path environment variable

# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode

"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$1" "$2" | cat

git-mergetool-diffmerge-wrapper.sh

# place this file in the Windows Git installation directory /cmd folder
# be sure to add the ../cmd folder to the Path environment variable

# passing the following parameters to mergetool:
# local base remote merge_result

"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$1" "$2" "$3" --result="$4" --title1="Mine" --title2="Merge" --title3="Theirs"
Git使用技巧_第2张图片
Paste_Image.png
Git使用技巧_第3张图片
Paste_Image.png

2)将\cmd设置环境变量,方便找


Git使用技巧_第4张图片
Paste_Image.png

3)黑掉Git配置文件
找到.gitconfig文件(路径在Windows“用户”路径下),
相关内容用下面的替换

[merge]
    tool = diffmerge
[diff]
    tool = diffmerge
[mergetool]
    keepBackup = false
[mergetool "diffmerge"]
    cmd = git-mergetool-diffmerge-wrapper.sh "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
[difftool "diffmerge"]
    cmd = git-difftool-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"

4)解决中文乱码问题

Git使用技巧_第5张图片
Paste_Image.png

Git使用技巧_第6张图片
Paste_Image.png

你可能感兴趣的:(Git使用技巧)