Review and refine Git diffs before you push.
Installation
Homebrew (macOS & Linux)
brew install difi
Go Install
go install github.com/xguot/difi/cmd/difi@latest
AUR (Arch Linux)
Binary (pre-built):
pikaur -S difi-bin
Build from source:
pikaur -S difi
Manual (Linux / Windows)
- Download the binary from Releases and add it to your
$PATH.
Workflow
Run difi in any Git repository against main:
cd my-project
difi
To compare against a specific branch or commit, just pass it as an argument:
# Compare against the main branch
difi main
# Compare against the previous commit
difi HEAD~1
Piping & Alternative VCS
You can also pass raw diffs directly into difi via standard input. This is perfect for patch files or other version control systems like Jujutsu:
# Review a saved patch file
difi < changes.patch
# Review changes in Jujutsu (jj)
jj diff --git | difi
# Pipe standard git diff output
git diff | difi
Controls
| Key |
Action |
Tab |
Toggle focus between File Tree and Diff View |
j / k |
Move cursor down / up |
h / l |
Focus Left (Tree) / Focus Right (Diff) |
e / Enter |
Edit file (opens editor at selected line) |
? |
Toggle help drawer |
q |
Quit |
Configuration
difi can be configured using a YAML file located at ~/.config/difi/config.yaml. If the file doesn't exist, difi will use sensible defaults.
Example config.yaml
editor: "nvim"
ui:
line_numbers: "hybrid"
theme: "default"
diff_add_bg: "#2b3328" # Optional: Custom background for added lines
diff_del_bg: "#4a2323" # Optional: Custom background for deleted lines
Options
| Key |
Default |
Description |
editor |
$DIFI_EDITOR, $EDITOR, $VISUAL, or vi |
The editor to open when pressing e on a file. |
ui.line_numbers |
"hybrid" |
The style of line numbers in the diff view. |
ui.theme |
"default" |
The core theme used for syntax highlighting. |
ui.diff_add_bg |
"" |
Hex code or terminal color for added line backgrounds. |
ui.diff_del_bg |
"" |
Hex code or terminal color for deleted line backgrounds. |
Integrations
vim-fugitive
- The "Unix philosophy" approach: Uses the industry-standard Git wrapper to provide a robust, side-by-side editing experience.
- Side-by-Side Editing: Instantly opens a vertical split (:Gvdiffsplit!) against the index.
- Merge Conflicts: Automatically detects conflicts and opens a 3-way merge view for resolution.
- Config: Add the line below to if using lazy.nvim.
{
"tpope/vim-fugitive",
cmd = { "Gvdiffsplit", "Git" }, -- Add this line
}
difi.nvim
Get the ultimate review experience with difi.nvim.
- Auto-Open: Instantly jumps to the file and line when you press
e in the CLI.
- Visual Diff: Renders diffs inline with familiar green/red highlights—just like reviewing a PR on GitHub.
- Interactive Review: Restore a "deleted" line by simply removing the
- marker. Discard an added line by deleting it entirely.
- Context Aware: Automatically syncs with your
difi session target.
Git Integration
To use difi as a native git command (e.g., git difi), add it as an alias in your global git config:
git config --global alias.difi '!difi'
Now you can run it directly from git:
git difi
Contributors
Star History