简体   繁体   中英

Configure git mergetool with Sublimerge

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?

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM