I can not do git diff use opendiff

I want to use opendiff as the default comparison tool for git diff. It worked, but for some reason it stopped working. I am using a script:

echo opendiff $2 $5 > opendiff-git.sh 

which is installed in .gitconfig:

 [diff] external = ~/opendiff-git.sh 

Recently, it has stopped working. What's wrong?

Update: When I cloned the new repository, everything worked fine! Weird!

+7
source share
3 answers

I found this question while I was trying to install opendiff as a git diff and merge tool. The strange thing is that when I used echo opendiff $ 2 $ 5> opendiff-git.sh to create a script, the script did not contain the argument holders $ 2 $ 5, I added them manually and started working!

This team

 echo opendiff $2 $5 > opendiff-git.sh 

Result in opendiff-git.sh file containing

 opendiff 

I added two arguments to the $ 2 $ 5 placeholder manually

 opendiff $2 $5 

Created a shell script executable as suggested by knittl

 chmod +x ~/opendiff-git.sh 

And it works!

+2
source

make sure your opendiff-git.sh file has its own executable bits:

 chmod +x ~/opendiff-git.sh 
+2
source

Now you can specify the default tool using git config . To use FileMerge, i.e. opendiff , run:

 git config --global diff.tool opendiff 

If you look at the ~/.gitconfig , you should see:

 [diff] tool = opendiff 

Now it should work.

+1
source

All Articles