Skip to content

Instantly share code, notes, and snippets.

Last active January 27, 2023 08:11
What would you like to do?
Use PHPStorm/WebStorm for git diff and merge tools
# ~/.gitconfig
# Add this to your global git configuration file
# Change phpstorm to webstorm, if you use that.
# Diff and merge tool changes
# Run `git difftool <directory/file>...` or `git mergetool <directory/file>...`
tool = phpstorm
tool = phpstorm
; This setting is optional, but prevents an annoying prompt between diffing files.
prompt = false
[difftool "phpstorm"]
; Putting this path here doesn't work. I would love to know why.
; path = /Applications/
cmd = webide diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")
trustExitCode = true
[mergetool "phpstorm"]
cmd = webide merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = true
# Add this to your .profile, .zshrc, .bashrc, etc.
# Add PHPStorm's bin directory to your path.
export PATH="/Applications/$PATH"
Copy link

If you can not find wstorm, open WebStorm, and go to Tools in menu bar then click Command-line Laucher. My WebStorm version is 2016.2.3.

BTW, I can directly use the solution of @JohnAlbin. Thanks.

Copy link

zored commented Jan 30, 2018

  • You can also configure it with commands like git config --global mergetool.pstorm.trustExitCode true.
  • You can use difftool --dir-diff, but currently tmp-files may be instantly removed, so I appended my difftool.pstorm.cmd with ; read and press Enter after diff completion.

Copy link

FYI: @zored I had to use && read instead on my system, in order for it to not delete the files before I'm done with them.
But that way, it works (for me too). Great work around, though! 👍 😉

P.S.: adding an additional --symlinks flag to the difftool --dir-diff is also a nice "upgrade"...

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