Merging files in Sublime with Sublimerge via command line

前端 未结 4 992
栀梦
栀梦 2021-01-02 00:08

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

相关标签:
4条回答
  • 2021-01-02 00:42

    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
    0 讨论(0)
  • 2021-01-02 00:46

    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}\"
    
    0 讨论(0)
  • 2021-01-02 00:55

    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!

    0 讨论(0)
  • 2021-01-02 00:56
     subl -n --wait "<LEFT>" "<RIGHT>" --command "sublimerge_diff_views {\"left_read_only\": true, \"right_read_only\": true}"
    

    See "VCS Integration" for details.

    0 讨论(0)
提交回复
热议问题