This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
difftastic¶
difftastic
is a structural diff tool that compares files based on their syntax.
Table of contents¶
Install¶
Config¶
Git external diff¶
-
Git supports external diff tools. You can use
GIT_EXTERNAL_DIFF
for a one-off git command, e.g.: -
If you want to use difftastic by default, use
git config
:$ git config diff.external difft # Set git configuration for the current repository $ git config --global diff.external difft # Set git configuration for all repositories
After running
git config
,git diff
will usedifft
automatically. Other git commands require--ext-diff
to use external diff, e.g.git log
andgit show
: -
See also git diff.
git-difftool
¶
-
git difftool is a git command for viewing the current changes with a different diff tool. It's useful if you want to use difftastic occasionally.
-
Add the following to your
.gitconfig
to use difftastic as your difftool:$ vi $HOME/.gitconfig # or $XDG_CONFIG_HOME/git/config or wherever > ... + > + > [diff] + > tool = difftastic + > + > [difftool] + > prompt = false + > + > [difftool "difftastic"] + > cmd = difft "$LOCAL" "$REMOTE" + > + > [pager] + > # Use a pager for large output, just like other git commands + > difftool = true + > + > [alias] + > # `git dft` is less to type than `git difftool` + > dft = difftool
-
You can then run
$ git difftool
to see current changes with difftastic. -
See also git difftool.
Use¶
-
Diffing files:
-
Diffing directories:
Difftastic will recursively walk the two directories, diffing files with the same name.The --skip-unchanged option is useful when diffing directories that contain many unchanged files.
-
You can read a file from
stdin
by specifying-
as the file path: -
Difftastic guesses the language used based on the file extension, file name, and the contents of the first lines. You can override the language detection by passing the
--language
option. Difftastic will treat input files as if they had that extension, and ignore other language detection heuristics. -
Difftastic includes a range of configuration CLI options, see
$ difft --help
for the full list. Difftastic can also be configured with environment variables. These are also visible in--help
. For example,DFT_BACKGROUND=light
is equivalent to--background=light
. This is useful when using tools like git, where you are not invoking thedifft
binary directly.
If this cheat sheet has been useful to you, then please consider leaving a star here.