How can I open a git diff in sublime from the terminal?
You can run the below commands to compare the changes for specific file: git diff HEAD <file_name> git diff <file_name>
Sublime Merge IntegrationThe Git features available in Sublime Text were derived from work that went into our other product, Sublime Merge. Sublime Merge is a full-featured, blazing-fast Git client built upon the technologies from Sublime Text.
Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
Install Git Plugin in Sublime Text In your text editor, open package installer using Cmd + Shift + P on Mac or Ctrl + Shift + P on windows. Go to Install Package -> Git. After successful installation, your can access commands of Git plugin using Cmd + Shift + P on mac and Ctrl + Shift + P on windows machine and type Git:.
Dev4.03.23.13.0 Sublime Text includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITORfor unix tools, such as git and subversion. Setup Windows Mac Linux Usage Configuring as EDITOR Setup
Dev4.03.23.13.0 Sublime Text includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITORfor unix tools, such as git and subversion.
By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached".
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With