Git Integration¶
Diffract can be registered as a git difftool for both file and directory comparisons. When called by Git, it opens the relevant paths in the GUI - and if Diffract is already running, the comparison appears in the existing window as a new tab rather than launching a second process.
File comparison (git difftool)¶
1. Add Diffract to your git config¶
```ini title="~/.gitconfig"
[diff]
tool = diffract
[difftool "diffract"]
cmd = diffract "$LOCAL" "$REMOTE"
[difftool]
prompt = false
```
Or run the equivalent git config commands:
git config --global diff.tool diffract
git config --global difftool.diffract.cmd 'diffract "$LOCAL" "$REMOTE"'
git config --global difftool.prompt false
2. Invoke it¶
Git opens each changed file pair in turn. If Diffract is already open, each pair is routed to the running window as a new tab via the IPC service - no additional processes are spawned.
To compare a specific file:
To compare against a specific commit or branch:
Directory comparison (git difftool --dir-diff)¶
The --dir-diff flag makes Git build two temporary directory trees (one per side) and pass them to the tool as a single call. Diffract automatically detects directory paths and opens a directory comparison.
No additional configuration is needed beyond the setup above. Run:
Or to compare a specific commit range:
The temporary directories mirror the repository layout, so folder structure, filenames, and subdirectory nesting are preserved exactly as they appear in the repository.
Three-way merge (git mergetool)¶
Pro feature
Three-way merge requires a Pro licence. Activate your licence to unlock it.
For a full guide to the three-way merge editor, see Three-Way Merge.
1. Add Diffract to your git config¶
```ini title="~/.gitconfig"
[merge]
tool = diffract
[mergetool "diffract"]
cmd = diffract --merge --base "$BASE" --left "$LOCAL" --right "$REMOTE" --output "$MERGED"
trustExitCode = true
[mergetool]
prompt = false
```
Or run the equivalent git config commands:
git config --global merge.tool diffract
git config --global mergetool.diffract.cmd 'diffract --merge --base "$BASE" --left "$LOCAL" --right "$REMOTE" --output "$MERGED"'
git config --global mergetool.diffract.trustExitCode true
git config --global mergetool.prompt false
trustExitCode = true tells Git to treat a zero exit code as "merge saved" and non-zero as "aborted". Without it Git will prompt you to confirm each file manually.
2. Invoke it¶
Diffract opens a three-way merge window for each conflicted file. Resolve all conflicts, then press Ctrl+S or click Save output. The process exits automatically and Git marks the file as resolved.
Closing the window without saving causes Diffract to exit with a non-zero code, leaving the file marked as unresolved in Git.
3. Single-instance behaviour¶
If Diffract is already running, each merge request is forwarded to the existing window as a new tab and the invoking process exits immediately. Complete the merges at your own pace - Git does not block on individual tabs in this case.
Tips¶
Single-instance routing - Diffract's IPC service means that running git difftool on a repository with many changed files does not spawn a new process per file. All comparisons are forwarded to the single running window and opened as tabs.
Suppress .orig backup files - By default Git saves a filename.orig backup of each conflicted file before invoking the mergetool. To stop Git creating these files, run:
Context menu alternative - For ad-hoc comparisons outside of Git, the Context Menu integration lets you right-click any two files or folders in your OS file manager and open them directly in Diffract.