Sublime Forum

How to use as a git mergetool?

#1

Hi all,

What must be added to the .gitconfig file to run sublimemerge as a git mergetool?

0 Likes

#2

Hi Donileo,

prior adding code to ~/.gitconfig file, you have to add smerge to your path variable.

Refer below screenshot …

After configuring smerge using the instructions above, run the following in your git bash

git config --global merge.tool smerge

At last, add the following code in your ~./gitconfig file

[merge]
tool = smerge

To invoke the merge tool, run git mergetool from your git repository.

1 Like

#3

I’m using smerge as a mergetool now using git mergetool from the command line. This opens a 3-column view where I can start resolving merge conflicts.

After all conflicts have been resolved, I am left with a bunch of temporary files:

~/.c/s/P/LSP (feat/completion-label-details|MERGING|●2✖2✚2…) $ subl ~/.gitconfig
~/.c/s/P/LSP (feat/completion-label-details|MERGING|●2✖2✚2…) $ git mergetool
Merging:
stubs/sublime.pyi
tests/test_completion.py

Normal merge conflict for 'stubs/sublime.pyi':
  {local}: modified file
  {remote}: modified file

Normal merge conflict for 'tests/test_completion.py':
  {local}: modified file
  {remote}: modified file
~/.c/s/P/LSP (feat/completion-label-details|MERGING|●4…) $ git diff
~/.c/s/P/LSP (feat/completion-label-details|MERGING|●4…) $ git status
On branch feat/completion-label-details
Your branch is up to date with 'origin/feat/completion-label-details'.

All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:
	modified:   plugin/completion.py
	modified:   plugin/core/protocol.py
	modified:   stubs/sublime.pyi
	modified:   tests/test_completion.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	stubs/sublime.pyi.orig
	stubs/sublime_BACKUP_106927.pyi
	stubs/sublime_BACKUP_107057.pyi
	stubs/sublime_BASE_106927.pyi
	stubs/sublime_BASE_107057.pyi
	stubs/sublime_LOCAL_106927.pyi
	stubs/sublime_LOCAL_107057.pyi
	stubs/sublime_REMOTE_106927.pyi
	stubs/sublime_REMOTE_107057.pyi
	tests/test_completion.py.orig

Should smerge remove these files after resolving the conflict, or is that git’s job?

0 Likes

#4

Hi @rwols,

Thanks for the question - these are files that Git generates and will typically clean up after the merge completes!

The only usual situation where these files remain are if you’ve set mergetool.keepTemporaries and the merge tool exits with a non-zero status.

Hope this helps,
- Dylan

1 Like