Skip to main content

Git Integration

Differens plugs into your normal git diff workflow. Instead of line hunks, it reports the semantic changes: renames, moves, added parameters.

Install the driver

One command registers Differens as a git diff driver in your repo’s local config and writes the .gitattributes rules itself:
The command registers every extension with a working grammar, or the subset pinned in the config file’s driverExtensions. Existing .gitattributes lines are preserved: a line already matching an extension keeps its other attributes and gains the driver, every other line passes through, and running the command twice changes nothing. To cover fewer extensions, list them in differens.toml. Files without the attribute keep normal git diff output. Now git diff on a .ts file shows the change instead of a hunk:
The driver receives both versions of every changed file, so this works in git diff, git diff --staged, and git difftool. To remove the driver later, unset the config. See the note in the git package reference.

Standalone modes

No git driver required. differens reads git directly.

Working tree

With no arguments, differens diffs the working tree against HEAD and correlates the changes across files:
This is git diff HEAD in semantic form. It picks up unstaged and staged changes, plus untracked files: a brand-new file is the most important change to report, so it is merged in from git ls-files --others.

Commit ranges

Diffs every file that changed between two refs. Output is grouped per file, with cross-file moves reported at the end:

Two commits

Both arguments resolve as git refs, so two SHAs or branch names diff like a range:

Two directories

If both arguments are directories, Differens walks each one and diffs matching relative paths:
Files present on only one side are whole-file additions or removals, and a file that moved to a different relative path reports as a rename (or a rename plus edit) rather than a delete and an add. Generated and vendor directories (node_modules, dist, .git, …) are skipped. There is no size cap: every file is read and diffed for real.

How it compares to git diff