How can I view the output of `git show` in a diff viewer like meld, kdiff3, etc
Solution 1:
You can use git difftool
to show a single commit.
Say you want to see the commit with the sha1 abc123
:
git difftool abc123~1 abc123
(~1
tells git to move to the previous commit, so abc123~1
is the commit before abc123
)
If you use this regularly, you could make a custom git command to make it easier:
-
Create a file called
git-showtool
somewhere on your$PATH
with the following contents:git difftool $1~1 $1
-
Give that file execute permissions:
chmod +x ~/path/to/git-showtool
Use the command
git showtool <sha1 or tag or ...>
- Profit.
Solution 2:
Building on georgebrock's response, you can create an alias in .gitconfig, something like this:
showtool = "!showci () { rev=${1:-HEAD}; git difftool $rev~1 $rev; }; showci $1"
Then you can run it with git showtool abc123
(without needing to create a separate shell script for this). If you leave out the revision it will default to HEAD.
Solution 3:
Translating sagittarian's suggestion for the less git savvy, add this to your global .gitconfig file which resides in C:\Users[user name] if you are a windows user:
[alias]
showtool = "!showci () { rev=${1:-HEAD}; git difftool $rev~1 $rev; }; showci $1"
or you can execute the following command in the get bash shell:
git config --global alias.showtool '!showci () { rev=${1:-HEAD}; git difftool $rev~1 $rev; }; showci $1'
which will make the change to the .gitconfig file for you.