Skip to content

Instantly share code, notes, and snippets.

@ObjectBoxPC
Created November 25, 2020 20:36
Show Gist options
  • Save ObjectBoxPC/7c70e7657b42c542f0ba2cdf9145172b to your computer and use it in GitHub Desktop.
Save ObjectBoxPC/7c70e7657b42c542f0ba2cdf9145172b to your computer and use it in GitHub Desktop.
"git sct" script ("show commit with tool") to view the changes made in a commit using a diff tool
#!/bin/sh
# To integrate, place the following into your .gitconfig:
# [alias]
# sct = !path/to/git-sct.sh
if [ $# -lt 1 ]; then
echo "Usage: git sct <revision> [<parent-number>]"
exit 1
fi
REVISION="$1"
PARENT_NUMBER="$2"
exec git difftool "$REVISION^$PARENT_NUMBER" "$REVISION"
@ObjectBoxPC
Copy link
Author

This can actually be replaced by the following alias: sct = !sh -c 'git difftool "$0^${1:-1}" "$0"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment