Open git diff in sublime from command line
diff, git, pipe, sublimetext
Solution
First, make sure you have the subl command accessible from the command line: Open Sublime Text from Terminal in macOS
Next, in your .profile or .bashrc or wherever you keep your aliases, add:
#open diff in sublime.
#ex: gd
#ex: gd head^
#ex: gd 7b3f441147f7c3c4b27bb7c9658aef27e3d0a5eb ee49bbc57f7376bc9f5c951e13808cb6b66be3d8
gd() {
if [ $# -eq 0 ]
then
git diff | subl
else
git diff $@ | subl
fi
}
And you can now open your diffs in sublime right from your terminal.
Problem
How can I open a git diff in sublime from the terminal?