使用Sublimerge配置git mergetool

问题描述 投票:7回答:2

我配置我的git来解决与Sublimerge的合并冲突。为此,我跑了:

git config --global merge.tool sublimerge

git config --global mergetool.sublimerge.cmd 'subl -n --wait \"$REMOTE\" \"$BASE\"   \"$LOCAL\" \"$MERGED\" --command \"sublimerge_diff_views\"'

git config --global mergetool.sublimerge.trustExitCode 'false'

git config --global diff.tool sublimerge

git config --global difftool.sublimerge.cmd 'subl -n --wait \"$REMOTE\" \"$LOCAL\" --command \"sublimerge_diff_views {\\\"left_read_only\\\": true, \\\"right_read_only\\\": true}\"'

当我运行git mergetool时,Sublime将打开四列:.remote,.base,.local和当前文件。但是,所有列都是空的。

并且所有列名都有一个“在文件扩展名之后,如:file.php.REMOTE.44625.php”,file.php.BASE.44625.php“,file.php.LOCAL.44625.php”和file.php “那我就不能编辑冲突了。

有人可以帮帮我吗?

git sublimetext3 git-config mergetool
2个回答
7
投票

在〜/ .gitconfig中添加以下内容

[merge]
tool = sublimerge

[mergetool "sublimerge"]
cmd = subl -n --wait \"$REMOTE\" \"$BASE\" \"$LOCAL\" \"$MERGED\" --command \"sublimerge_diff_views\"
trustExitCode = false

[diff]
tool = sublimerge

[difftool "sublimerge"]
cmd = subl -n --wait \"$REMOTE\" \"$LOCAL\" --command \"sublimerge_diff_views {\\\"left_read_only\\\": true, \\\"right_read_only\\\": true}\"

0
投票

添加git merge工具作为sublime编辑器然后验证〜/ .gitconfig文件。

$git config --list

[email protected]
user.name=xyz
color.ui=true
color.status=auto
color.branch=auto
push.default=matching
branch.autosetuprebase=always
core.editor=subl -n -w
merge.tool=sublimerge
mergetool.sublimerge.cmd=subl -n --wait \"$REMOTE\" \"$BASE\"   \"$LOCAL\" \"$MERGED\" --command \"sublimerge_diff_views\"
mergetool.sublimerge.trustexitcode=false
diff.tool=sublimerge
difftool.sublimerge.cmd=subl -n --wait \"$REMOTE\" \"$LOCAL\" --command \"sublimerge_diff_views {\\\"left_read_only\\\": true, \\\"right_read_only\\\": true}\"

如果没有反映,则手动添加合并工具详细信息

$vim ~/.gitconfig

[core]
        editor = subl -n -w
[merge]
        tool = sublimerge
[mergetool "sublimerge"]
        cmd = subl -n --wait \\\"$REMOTE\\\" \\\"$BASE\\\"   \\\"$LOCAL\\\" \\\"$MERGED\\\" --command \\\"sublimerge_diff_views\\\"
        trustExitCode = false
[diff]
        tool = sublimerge
[difftool "sublimerge"]
        cmd = subl -n --wait \\\"$REMOTE\\\" \\\"$LOCAL\\\" --command \\\"sublimerge_diff_views {\\\\\\\"left_read_only\\\\\\\": true, \\\\\\\"right_read_only\\\\\\\": true}\\\"
© www.soinside.com 2019 - 2024. All rights reserved.