Set git default diff- and mergetool to pyCharm

Hello,
I'd like to have pyCharm set as my default diff- and mergetool for git.

For instance if I type merge command in console and if conflict occurs pyCharm will be opened instead of that vi-style-looking default difftool.
6 comments
Comment actions Permalink
PyCharm's diff tool can be invoked from the command line as 'pycharm diff <file1> <file2>', and the merge tool can be invoked as 'pycharm merge <file1> <file2> <origin>'.
0
Comment actions Permalink
It seems that the command is 'charm diff <file1> <file2>' rather 'pycharm diff <file1> <file2>' ( I am on Ubuntu )

However I am not sure what are these arguments 'file1', 'file2'?

I use git and I want to compare a file from current revision with the very same file from previous revision, but I don't know where the file from previous revision resides.

If it works in such a way that I have to type:
'charm diff <file_from_current_revision> <file_form_previous_revision>'
then it is pretty unhandy...

Is there any way to set that command to always work in following way:
charm diff fileX
to launch PyCharm diff tool on fileX from current revision and fileX from previous revision?
0
Comment actions Permalink
This is really a Git question, not a PyCharm question. PyCharm's standalone diff tool has no integration with any version control system and has no concept of "file X from previous revision".
0
Comment actions Permalink
Ah, well true, I expected PyCharm to do something it is not designed for.

Thanks for your answer.
0
Comment actions Permalink

<disclaimer>

I'm still very new to both git, github, and to pycharm.  

And

I've not actually written the following script to see if it works yet.  

</disclaimer>

I did notice that this question was unresolved, and I noticed because I had the same question myself.  So in the interest in potentially helping (even though this thread is 7 years old!) I provide the following link from git-scm (https://git-scm.com/docs/git-difftool) which indicates that you can customize git difftool to "o run an alternative program by specifying the command line to invoke..." which includes env variables that appear to have pointers to the before and after, implying a simple scrip will make the translation to [pycharm | charm] merge <file1> <file2>.  I've added it to (the bottom) of my list of things, and if I remember, I'll post back the script that works (or doesn't).

 

 

 

0
Comment actions Permalink

OK.  I've got an alternative solution that appears to be working.

And I must say that the diff tool in pycharm is quite nice, now that I see it working!

 

Starting here:

https://coderwall.com/p/h1m3pw/setting-your-own-difftool 

 

I added this to my ~/.gitconfig

[difftool "pycharm64"]
cmd = \"C:/Program Files/JetBrains/PyCharm 2020.1.2/bin/pycharm64.exe\" diff \"$LOCAL\" \"$REMOTE\"

Note that I'm using forward slashes so I don't have to deal with escaping the back slashes.

Note also that I have escaped out the outer quotes

0

Please sign in to leave a comment.