Skip to content

Instantly share code, notes, and snippets.

@witoszekdev
Last active February 21, 2022 14:41
Show Gist options
  • Save witoszekdev/c36f9143e589ea6ffb3a06c029a8add1 to your computer and use it in GitHub Desktop.
Save witoszekdev/c36f9143e589ea6ffb3a06c029a8add1 to your computer and use it in GitHub Desktop.
Git configuration for using WebStorm as mergetool

WebStorm

as git mergetool

Don't like using VSCode merge conflicts resolution? Try WebStorm's instead.

or any other Jetbrains IDE. If you don't want to buy Webstorm's licence try PyCharm Community Edition instead.

1. Generate shell scripts

Open your Jetbrains Toolkit and enable generation of shell scripts. Provided the folder that exists in your $PATH. I've used /usr/local/bin.

Configuration inside Jetbrains Toolkit application

2. Edit .gitconfig

Open ~/.gitconfig file (it should be in your home directory) in your favourite editor and add this configuration

[merge]
  tool = webstorm
[diff]
  tool = webstorm
[mergetool]
  keepBackup = false
[mergetool "webstorm"]
  cmd = webstorm merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" && read
[difftool "webstorm"]
  cmd = webstorm diff $LOCAL $REMOTE --wait
  trustExitCode = true

This will use WebStorm as your default mergetool and difftool.

Note: If you're using different Jetbrains IDE use it's name instead of webstorm. For example, for PyCharm:

[merge]
  tool = pycharm
[mergetool "pycharm"]
  cmd = pycharm merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" && read

The keepBackup = false will disable git creating *.orig files when performing merge

3. Resolve merge conflict

When you encounter merge conflicts just run git mergetool to open up WebStorm. Don't worry it won't open the entire IDE, just the merge conflict resolution tool.

To speed up the startup time of WebStorm keep it open in the backgroud. You don't need to open any project.

After you've resolved the conflicts press Enter in the commandline. WebStorm will open for each conflicting file.

Wait! Why doesn't VSCode have this feature? Well... there's been a proposal from 2017, but since then VSCode team have removed this feature from the roadmap

Using WebStorm for merge conflict resolution

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