FileMerge (opendiff) can really come in handy when you need to visually compare merging conflicts. Other times it's just a nice visual way to review your days work.
The following method works by creating a simple bash script (git-diff-cmd.sh) that sets us up with the proper command line arguments for Git to pass off files to FileMerge.
-
Open the bash script for editing:
vi ~/bin/git-diff-cmd.sh
-
Paste the following code:
#!/bin/sh /usr/bin/opendiff "$2" "$5" -merge "$1"
-
Make the bash script executable:
chmod +x ~/bin/git-diff-cmd.sh
-
Tell Git (globally) to run our bash script when 'git diff' is issued:
git config --global diff.external ~/bin/git-diff-cmd.sh
Now head over to your Git-aware project directory and issue a
git diff /path/to/modified/file.py
and FileMerge will pop up showing you the
differences against it and HEAD.
You can also do things like git diff --cached
to review all the changes
against HEAD.
Similar to the advice from @nicholasruunu, you can use FileMerge with git by running these commands:
One-time setup:
Perform a diff with FileMerge:
If you don't want to be prompted before opening each file, you can run this:
Note: When using the
git difftool
option, you will have to quit FileMerge after each file is shown, and then git will show you the next one. In contrast, the original script above opens all the files at once.By the way, if you want to undo the original setup, you can run this command:
If you want to undo the difftool setup, you can run these commands:
I think you can also use FileMerge for merges via this command (see http://stackoverflow.com/a/20123093/3830997), but I haven't tried it: