Mergetool Sublime Merge
adminApril 28 2021
Mergetool Sublime Merge
Sublime Merge and Sublime Text share a bunch of low-level code, various aspects like the syntax definitions and engine, the UI library, rendering backends, and a whole bunch more. The higher-level UI components and the exact way they are put together are different, but there is a lot shared. Sublime Merge can now be used as a standalone merge tool, to merge arbitrary files, integrate with another version control system, or use from the command line via git mergetool. This functionality is available via the smerge command line helper. Sublime Merge Build 1107 is available for Windows, Mac and Linux, from the Download page. A protip by sheerun about sublime and git.
Here i want to show how to resolve conflicts while merging git branches. It is not the only method but one of.
Let's use Meld for this task:
First install it:
$ sudo add-apt-repository ppa:tsvetko.tsvetkov/trusty-backports
$ sudo apt-get update
$ sudo apt-get install meld
And use:
$ git mergetool -t meld
If you have conflict, you will see something like this:
Three windows are shown, and left to right are:
- The local branch (master branch)
- The current version that you are merging into (final solution)
- The “remote” version (from the other branch)
Git Mergetool Sublime Merge
To choose the text from the desired brunch, click on the black arrow, showing direction. Meldcopies the text to the other file, and removes the text from where it was). In the end you have to save file and resolve conflict in Git.
Configure Git For Your Mergetool Of Choice
There are many merge tools available and everybody has their own favorites.
To configure git to remember which merge tool you want, type git config –global merge.tool [tool]. For meld use:
$ git config --global merge.tool meld
Besides built-in support for the most popular Version Control Systems, Sublimerge can be also integrated with them as a diff and merge tool. Because it can be run from command line, you can integrate it with anything. Please be aware of possible integration issues.
Mergetool Sublime Merge
Command templates
All examples here assumes that Sublime Text binary is in your PATH. Here `subl` is used to refer to Sublime Text executable, but remember that under Windows this will be `sublime_text.exe`.
Prepare environment (OS X)
Sublime Text requires a little setup under Mac OS X.
Assuming you've installed Sublime Text in Applications and you have a ~/bin directory in your PATH, please do the following to create a symlink to Sublime's binary:
- Sublime Text 2
- Sublime Text 3
This way you get subl command that this document refers to.
Diff tool (2-way)
Merge tool (3-way)
Available parameters
- left_read_only true/false
- When true, opens left file in read only mode. For 2-way diff defaults to false. For 3-way diff is always forced to true.
- right_read_only true/false
- When true, opens left right in read only mode. For 2-way diff defaults to false. For 3-way diff is always forced to true.
- full_screen false
- Whether to open diff view in full screen mode. Possible values: true, false, null. When set to null, defaults to full_screen value from Sublimerge config.
TortoiseGit/TortoiseSVN
Diff tool
Merge tool
Git
~/.gitconfigSublime Merge Mergetool
Mercurial (Hg)
~/.hgrcSubversion (SVN)
SVN configuration is a little bit complicated. It requires creating two bash scripts (Windows users will need to create similar BAT files) for svn diff --diff-cmd and svn diff --diff3-cmd commands.
2-way diff script
To run Sublimerge on modified files, run the following command:
3-way diff script
To resolve conflicts during update, run the following command:
To make it default for svn diff command, put the following contents into ~/.subversion/config:
Possible integration issues
- ST2/ST3: running Sublimerge from command line restores last Sublime's session (only when ST was not already running).
- Probably there is no good way to fix this since this is 'normal' Sublime's behavior. See this discussion for more information and possible solution.
- ST3: running Sublimerge from command line (only when Sublime Text was not already running) only opens files without doing diff. Otherwise, when launching Sublimerge while ST is running, everything works fine.
- This is caused by asynchronous plugins loader in ST3 and cannot be fixed from plugin level.
- OS X: When MacPorts version of Python is installed, running Sublimerge fails when there is no Sublime Text instance running.
- According to information on this page, please open Sublime Text first and then run Sublimerge via subl command.
Mergetool Sublime Merge