【问题标题】:Configure git mergetool with Sublimerge使用 Sublimerge 配置 git mergetool
【发布时间】:2014-07-20 13:42:54
【问题描述】:

我配置了我的 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”。然后我无法编辑冲突。

谁能帮帮我?

【问题讨论】:

  • stackoverflow.com/q/19297084/6309 的答案之一会有帮助吗?
  • @VonC,不...我已经看到了这个答案。
  • 它是否有效git difftool?崇高的文本控制台(ctrl`)中有什么吗?大概你正在使用 linux/mac?你在全局配置文件 ~/.gitconfig 中得到了什么?
  • 使用 Git 2.22(2019 年第二季度,五年后),git config --global merge.tool smerge 就足够了。见my answer below

标签: git sublimetext3 git-config mergetool


【解决方案1】:

在你的 ~/.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}\"

【讨论】:

  • 这对我有用,在命令 $> git difftool 并回答提示 Y/n 之后。
【解决方案2】:

添加 git 合并工具作为 sublime 编辑器后,然后验证 ~/.gitconfig 文件。

$git config --list

user.email=xyz@live.com
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}\\\"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-21
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 2023-04-04
    • 2016-03-11
    • 1970-01-01
    相关资源
    最近更新 更多