Search code examples
gitsshdiffmeld

How can I have a graphical 'diff' for git when working locally and also use diff via SSH?


I currently use meld for git diff. I have configured it this way:

I've added git-meld to /bin:

#!/bin/bash
meld "$2" "$5"

made it executable

chmod +x git-meld

and added it to my git configuration:

git config --global diff.external git-meld

This works fine when I work locally. But when I'm logged in via SSH, I get an error message.

It would be great if I could use meld while I'm logged in via SSH, but using the standard diff would also be ok.

So my question is: How can I have a graphical 'diff' for git when working locally and also use diff via SSH?


Solution

  • Change your git-meld script roughly like this:

    if [ $DISPLAY ]; then
        exec meld "$2" "$5"
    else
        exec diff "$2" "$5"
    fi