Skip to content

Instantly share code, notes, and snippets.

@jonlabelle
Created March 27, 2019 16:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonlabelle/8cc3a5cc08f965f2f9ad95e2617fdfb3 to your computer and use it in GitHub Desktop.
Save jonlabelle/8cc3a5cc08f965f2f9ad95e2617fdfb3 to your computer and use it in GitHub Desktop.
Sublime Merge Command Line Usage

Sublime Merge Command Line Usage

Sublime Merge includes a command line tool, smerge, to work with repositories on the command line. This can be used to open repositories, search, and merge files.

Setup

Windows

Add C:\Program Files\Sublime Merge to your environment %PATH% variable.

macOS

You'll want to add a symlink (symbolic link) to smerge. Assuming you've placed Sublime Merge in the Applications folder, and that you have a ~/bin directory in your path, you can run:

ln -s "/Applications/Sublime Merge.app/Contents/SharedSupport/bin/smerge" ~/bin/smerge

Linux

smerge should already be available by default. However, it won't be if you're using a tarball, so you'll want to add a symlink to sublime_merge named smerge:

ln -s /opt/sublime_merge/sublime_merge ~/bin/smerge

Git Merge Tool Setup

The merge tool can be used to process merge conflicts within a Git repository from the command line.

After configuring smerge using the instructions above, run the following from the repository directory:

git config mergetool.smerge.cmd 'smerge mergetool "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"'
git config mergetool.smerge.trustExitCode true
git config merge.tool smerge

Git Merge Tool Usage

To invoke the merge tool, run:

git mergetool

Reference Sublime Merge Command Line Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment