13

I'm trying to find a better merge file option and wanted to try out Sublime as of my work is done using it. so I installed Sublimerge and now am stuck. I know I can compare two already open files or compare via the Sidebar but what I want to do is fire it off via the command line so I can kick it off from our source control program like I can with every other merge tool I've seen. Does anyone know the command line format to do this?

N.B. - I've long since given up trying to use sublime to handle merges and instead switched to other tools to handle this. Therefore I've never felt I can accept any answer as I'm not checking them to see if they work in the way I'd want, or indeed whether they work at all.

denfromufa
  • 5,610
  • 13
  • 81
  • 138
Andy Davies
  • 666
  • 9
  • 23

4 Answers4

5
 subl -n --wait "<LEFT>" "<RIGHT>" --command "sublimerge_diff_views {\"left_read_only\": true, \"right_read_only\": true}"

See "VCS Integration" for details.

Patrick Fisher
  • 7,926
  • 5
  • 35
  • 28
Nickolay
  • 31,095
  • 13
  • 107
  • 185
5

As Nickolay already suggested, this is the whole directive you have to put in your ~/.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}\"
jnns
  • 5,148
  • 4
  • 47
  • 74
5

Taking jnns' answer, but making appropriate changes for windows.

%USERPROFILE%\.gitconfig:

[merge]
    tool = sublimerge

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

[diff]
    tool = sublimerge

[difftool "sublimerge"]
    cmd = sublime_text -n --wait \"$REMOTE\" \"$LOCAL\" --command \"sublimerge_diff_views {\\\"left_read_only\\\": true, \\\"right_read_only\\\": true}\"
  • note location of .gitconfig
  • in windows, the executable is sublime_text.exe, NOT subl
  • don't forget to add sublime text executable to the path
jlee
  • 464
  • 6
  • 9
1

I'm not sure exactly how to do it, but I'm getting closer.

First, you need a handy path to the Sublime binary:

mkdir ~/bin
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Then, in your git GUI or git command line, configure ~/bin/subl as your merge tool.

I use Source Tree, and I haven't figured exactly how to best use Sublimerge, but I managed to open both versions, merge them, and then I have to do a bit of manual work.

Still not smooth, but better than nothing!

superiggy
  • 1,023
  • 8
  • 14
  • Totally forgot I posted this question. I managed to get sublime fired off from my source control, but it wasn't very slick, kept leaving files open that it shouldn't have and wasn't a very nice experience all told. I don't think sublimemerge is really up to the job. – Andy Davies Nov 19 '13 at 11:24
  • I'm using sublime and sublimerge but using sublime for ```mergetool``` juts open both version in a splitted window not using sublimerge. Do you managed to open both versions in ```sublimerge``` or in standard sublime splitted window ? – svassr Dec 16 '13 at 22:21
  • No, like you are seeing it they were in a standard split window in sublime. I then had to use a certain key combination to select and open the right files in sublimerge. Which was a right faff as I'd often have multiple docs already open in sublime and then have to select the right ones. Considering sublime is hailed in some circles as a the bee's knees I'm a bit surprised that there isn't a proper story re merging. – Andy Davies Dec 18 '13 at 09:54