I\'m just starting to work with Git. I would like to use TortoiseMerge as the difftool and mergetool.
In my $HOME/.gitconfig
I have the following sections.
Great answer by Klas Mellbourn! Saved me a lotta time.
One shortcoming is, newly Added
or Removed
files in the repository will not show up during the difftool command execution. There's nothing to compare them to! Here's what I did on top of this:
(Inspired by my co-worker's answer).
empty.empty
in $Home
directory (execute start ~
in your bash). And as the name suggests, keep it empty.tortoisediff.sh
in $Home/bin
directory with following content:
#!/bin/sh
# $LOCAL $REMOTE seem to be swapped
# $1 is $LOCAL
# $2 is $REMOTE
difftool='/c/Program Files/TortoiseGit/bin/TortoiseGitMerge.exe'
NULL="/dev/null"
empty="C:/home/empty.empty"
if [ "$1" == "$NULL" ]; then
echo "Added: " "$2"
"$difftool" /base:"$empty" /mine:"$2" /readonly:"$empty"
elif [ "$2" == "$NULL" ]; then
echo 'Removed: ' "$1"
"$difftool" /base:"$1" /readonly:"$1" /mine:"$empty"
else
echo 'Modified' "$2"
"$difftool" /base:"$1" /basename:"$1" /readonly:"$1" /mine:"$2" /minename:"$2"
fi
# Checkout https://tortoisegit.org/docs/tortoisegitmerge/tme-automation.html for more
Modify your .gitconfig file (Line 11 of the answer)
cmd = tortoisediff.sh "$LOCAL" "$REMOTE"
This would now make difftool refer to tortoisediff.sh instead of opening the application directly.
git add .
followed by git difftool --staged
instead of simply git difftool
.