Configure git mergetool with Sublimerge
Asked Answered
F

2

7

I configured my git to resolve merge conflicts with Sublimerge. For this, I was run:

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}\"'

When I run git mergetool, the Sublime will opening with four columns: .remote, .base, .local and the current file. But, all columns are empty.

And all columns names has a " after the file extension, like: file.php.REMOTE.44625.php", file.php.BASE.44625.php", file.php.LOCAL.44625.php"and file.php". Then i cant edit the conflict.

Anybody can help me?

Finkelstein answered 30/5, 2014 at 17:53 Comment(4)
Would one of the answers of https://mcmap.net/q/870486/-merging-files-in-sublime-with-sublimerge-via-command-line/6309 be of any help?Astraea
@VonC, no... I alredy see this answers.Finkelstein
does it work git difftool? Is there anything in the sublime text console (ctrl `)? presumably you're usling linux/mac? What did you get in the global config file ~/.gitconfig ?Chasitychasm
With Git 2.22 (Q2 2019, five years later), a git config --global merge.tool smerge will be enough. See my answer below.Astraea
C
9

In your ~/.gitconfig add following

[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}\"
Concerto answered 14/7, 2015 at 20:44 Comment(1)
This worked for me, after command $> git difftool and answering the prompt Y/n.Lastex
J
0

after adding git merge tool as sublime editor then verify ~/.gitconfig file.

$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}\"

if not reflected then manually add merge tool details

$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}\\\"
Jovitta answered 19/8, 2017 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.