This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
difftastic is a structural diff tool that compares files based on their syntax.
Table of contents¶
Git external diff¶
Git supports external diff tools. You can use
GIT_EXTERNAL_DIFFfor a one-off git command, e.g.:
If you want to use difftastic by default, use
$ git config diff.external difft # Set git configuration for the current repository $ git config --global diff.external difft # Set git configuration for all repositories
git diffwill use
difftautomatically. Other git commands require
--ext-diffto use external diff, e.g.
See also git diff.
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
.gitconfigto 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 difftoolto see current changes with difftastic.
See also git difftool.
The --skip-unchanged option is useful when diffing directories that contain many unchanged files.
You can read a file from
-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
--languageoption. 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 --helpfor the full list. Difftastic can also be configured with environment variables. These are also visible in
--help. For example,
DFT_BACKGROUND=lightis equivalent to
--background=light. This is useful when using tools like git, where you are not invoking the
If this cheat sheet has been useful to you, then please consider leaving a star here.